<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>TURN Server: src/client++/TurnMsgLib.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">TURN Server
   &#160;<span id="projectnumber">1.5</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.8.0 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">src/client++/TurnMsgLib.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="TurnMsgLib_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * Copyright (C) 2012, 2013 Citrix Systems</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * All rights reserved.</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * Redistribution and use in source and binary forms, with or without</span>
<a name="l00007"></a>00007 <span class="comment"> * modification, are permitted provided that the following conditions</span>
<a name="l00008"></a>00008 <span class="comment"> * are met:</span>
<a name="l00009"></a>00009 <span class="comment"> * 1. Redistributions of source code must retain the above copyright</span>
<a name="l00010"></a>00010 <span class="comment"> *    notice, this list of conditions and the following disclaimer.</span>
<a name="l00011"></a>00011 <span class="comment"> * 2. Redistributions in binary form must reproduce the above copyright</span>
<a name="l00012"></a>00012 <span class="comment"> *    notice, this list of conditions and the following disclaimer in the</span>
<a name="l00013"></a>00013 <span class="comment"> *    documentation and/or other materials provided with the distribution.</span>
<a name="l00014"></a>00014 <span class="comment"> * 3. Neither the name of the project nor the names of its contributors</span>
<a name="l00015"></a>00015 <span class="comment"> *    may be used to endorse or promote products derived from this software</span>
<a name="l00016"></a>00016 <span class="comment"> *    without specific prior written permission.</span>
<a name="l00017"></a>00017 <span class="comment"> *</span>
<a name="l00018"></a>00018 <span class="comment"> * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS&#39;&#39; AND</span>
<a name="l00019"></a>00019 <span class="comment"> * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE</span>
<a name="l00020"></a>00020 <span class="comment"> * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE</span>
<a name="l00021"></a>00021 <span class="comment"> * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE</span>
<a name="l00022"></a>00022 <span class="comment"> * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL</span>
<a name="l00023"></a>00023 <span class="comment"> * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS</span>
<a name="l00024"></a>00024 <span class="comment"> * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)</span>
<a name="l00025"></a>00025 <span class="comment"> * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT</span>
<a name="l00026"></a>00026 <span class="comment"> * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY</span>
<a name="l00027"></a>00027 <span class="comment"> * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</span>
<a name="l00028"></a>00028 <span class="comment"> * SUCH DAMAGE.</span>
<a name="l00029"></a>00029 <span class="comment"> */</span>
<a name="l00030"></a>00030 
<a name="l00031"></a>00031 <span class="preprocessor">#ifndef __LIB_TURN_MSG_CPP__</span>
<a name="l00032"></a>00032 <span class="preprocessor"></span><span class="preprocessor">#define __LIB_TURN_MSG_CPP__</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span>
<a name="l00034"></a>00034 <span class="preprocessor">#include &quot;ns_turn_ioaddr.h&quot;</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include &quot;<a class="code" href="ns__turn__msg_8h.html">ns_turn_msg.h</a>&quot;</span>
<a name="l00036"></a>00036 
<a name="l00037"></a>00037 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00038"></a>00038 
<a name="l00039"></a><a class="code" href="namespaceturn.html">00039</a> <span class="keyword">namespace </span>turn {
<a name="l00040"></a>00040 
<a name="l00041"></a>00041 <span class="keyword">class </span><a class="code" href="classturn_1_1StunAttr.html">StunAttr</a>;
<a name="l00042"></a>00042 
<a name="l00046"></a><a class="code" href="classturn_1_1EndOfStunMsgException.html">00046</a> <span class="keyword">class </span><a class="code" href="classturn_1_1EndOfStunMsgException.html">EndOfStunMsgException</a> {
<a name="l00047"></a>00047 <span class="keyword">public</span>:
<a name="l00048"></a><a class="code" href="classturn_1_1EndOfStunMsgException.html#a91db380d1c20d683b5999fa68e94f79d">00048</a>         <a class="code" href="classturn_1_1EndOfStunMsgException.html#a91db380d1c20d683b5999fa68e94f79d">EndOfStunMsgException</a>() {}
<a name="l00049"></a><a class="code" href="classturn_1_1EndOfStunMsgException.html#abd13c75a9e14593d8419ea6d47771cf6">00049</a>         <span class="keyword">virtual</span> <a class="code" href="classturn_1_1EndOfStunMsgException.html#abd13c75a9e14593d8419ea6d47771cf6">~EndOfStunMsgException</a>() {}
<a name="l00050"></a>00050 };
<a name="l00051"></a>00051 
<a name="l00055"></a><a class="code" href="classturn_1_1WrongStunAttrFormatException.html">00055</a> <span class="keyword">class </span><a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a> {
<a name="l00056"></a>00056 <span class="keyword">public</span>:
<a name="l00057"></a><a class="code" href="classturn_1_1WrongStunAttrFormatException.html#ae4730ff81ece0fbd38320ca7170c0523">00057</a>         <a class="code" href="classturn_1_1WrongStunAttrFormatException.html#ae4730ff81ece0fbd38320ca7170c0523">WrongStunAttrFormatException</a>() {}
<a name="l00058"></a><a class="code" href="classturn_1_1WrongStunAttrFormatException.html#ac0e11278f3a1a1c45108eb6a77bc114a">00058</a>         <span class="keyword">virtual</span> <a class="code" href="classturn_1_1WrongStunAttrFormatException.html#ac0e11278f3a1a1c45108eb6a77bc114a">~WrongStunAttrFormatException</a>() {}
<a name="l00059"></a>00059 };
<a name="l00060"></a>00060 
<a name="l00064"></a><a class="code" href="classturn_1_1WrongStunBufferFormatException.html">00064</a> <span class="keyword">class </span><a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a> {
<a name="l00065"></a>00065 <span class="keyword">public</span>:
<a name="l00066"></a><a class="code" href="classturn_1_1WrongStunBufferFormatException.html#a0e5d426cb3c50b638fa1c10f28367b71">00066</a>         <a class="code" href="classturn_1_1WrongStunBufferFormatException.html#a0e5d426cb3c50b638fa1c10f28367b71">WrongStunBufferFormatException</a>() {}
<a name="l00067"></a><a class="code" href="classturn_1_1WrongStunBufferFormatException.html#a4ac0bea30ba1f088a02b5fa618a28545">00067</a>         <span class="keyword">virtual</span> <a class="code" href="classturn_1_1WrongStunBufferFormatException.html#a4ac0bea30ba1f088a02b5fa618a28545">~WrongStunBufferFormatException</a>() {}
<a name="l00068"></a>00068 };
<a name="l00069"></a>00069 
<a name="l00073"></a><a class="code" href="classturn_1_1StunAttrIterator.html">00073</a> <span class="keyword">class </span><a class="code" href="classturn_1_1StunAttrIterator.html">StunAttrIterator</a> {
<a name="l00074"></a>00074 <span class="keyword">public</span>:
<a name="l00078"></a><a class="code" href="classturn_1_1StunAttrIterator.html#aecef3110e09f0b2c9cf7c27efd01df51">00078</a>         <a class="code" href="classturn_1_1StunAttrIterator.html#aecef3110e09f0b2c9cf7c27efd01df51">StunAttrIterator</a>(u08bits *buf, <span class="keywordtype">size_t</span> sz) <span class="keywordflow">throw</span> (<a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) :
<a name="l00079"></a>00079                 _buf(buf), _sz(sz)  {
<a name="l00080"></a>00080                 <span class="keywordflow">if</span>(!<a class="code" href="ns__turn__msg_8h.html#a0ec34e642f8cbf785ecef76f7fb0d87b">stun_is_command_message_str</a>(_buf, _sz)) {
<a name="l00081"></a>00081                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>();
<a name="l00082"></a>00082                 }
<a name="l00083"></a>00083                 _sar = <a class="code" href="ns__turn__msg_8h.html#a2672e36b81e61e29c4e61dbdda0cc547">stun_attr_get_first_str</a>(_buf, _sz);
<a name="l00084"></a>00084         }
<a name="l00085"></a>00085 
<a name="l00089"></a>00089         <span class="keyword">template</span>&lt;<span class="keyword">class</span> T&gt;
<a name="l00090"></a><a class="code" href="classturn_1_1StunAttrIterator.html#ae19b078aa1f031ab186a8f483e56e104">00090</a>         <a class="code" href="classturn_1_1StunAttrIterator.html#aecef3110e09f0b2c9cf7c27efd01df51">StunAttrIterator</a>(T &amp;msg) <span class="keywordflow">throw</span> (<a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) :
<a name="l00091"></a>00091                 _buf(msg.getRawBuffer()), _sz(msg.getSize())  {
<a name="l00092"></a>00092                 <span class="keywordflow">if</span>(!<a class="code" href="ns__turn__msg_8h.html#a0ec34e642f8cbf785ecef76f7fb0d87b">stun_is_command_message_str</a>(_buf, _sz)) {
<a name="l00093"></a>00093                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>();
<a name="l00094"></a>00094                 }
<a name="l00095"></a>00095                 _sar = <a class="code" href="ns__turn__msg_8h.html#a2672e36b81e61e29c4e61dbdda0cc547">stun_attr_get_first_str</a>(_buf, _sz);
<a name="l00096"></a>00096         }
<a name="l00097"></a>00097 
<a name="l00102"></a><a class="code" href="classturn_1_1StunAttrIterator.html#a243eb3e610b737a48167d47ed819dd7c">00102</a>         <a class="code" href="classturn_1_1StunAttrIterator.html#aecef3110e09f0b2c9cf7c27efd01df51">StunAttrIterator</a>(u08bits *buf, <span class="keywordtype">size_t</span> sz, u16bits attr_type) <span class="keywordflow">throw</span> (<a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) :
<a name="l00103"></a>00103                         _buf(buf), _sz(sz)  {
<a name="l00104"></a>00104                 <span class="keywordflow">if</span>(!<a class="code" href="ns__turn__msg_8h.html#a0ec34e642f8cbf785ecef76f7fb0d87b">stun_is_command_message_str</a>(_buf, _sz)) {
<a name="l00105"></a>00105                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>();
<a name="l00106"></a>00106                 }
<a name="l00107"></a>00107                 _sar = <a class="code" href="ns__turn__msg_8h.html#a05ac5979839241de8b46e4ebdc145722">stun_attr_get_first_by_type_str</a>(_buf, _sz, attr_type);
<a name="l00108"></a>00108         }
<a name="l00109"></a>00109 
<a name="l00114"></a>00114         <span class="keyword">template</span>&lt;<span class="keyword">class</span> T&gt;
<a name="l00115"></a><a class="code" href="classturn_1_1StunAttrIterator.html#a7d8cfa4f462968f75a5732379b5cc1a6">00115</a>         <a class="code" href="classturn_1_1StunAttrIterator.html#aecef3110e09f0b2c9cf7c27efd01df51">StunAttrIterator</a>(T &amp;msg, u16bits attr_type) <span class="keywordflow">throw</span> (<a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) :
<a name="l00116"></a>00116                         _buf(msg.getRawBuffer()), _sz(msg.getSize())  {
<a name="l00117"></a>00117                 <span class="keywordflow">if</span>(!<a class="code" href="ns__turn__msg_8h.html#a0ec34e642f8cbf785ecef76f7fb0d87b">stun_is_command_message_str</a>(_buf, _sz)) {
<a name="l00118"></a>00118                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>();
<a name="l00119"></a>00119                 }
<a name="l00120"></a>00120                 _sar = <a class="code" href="ns__turn__msg_8h.html#a05ac5979839241de8b46e4ebdc145722">stun_attr_get_first_by_type_str</a>(_buf, _sz, attr_type);
<a name="l00121"></a>00121         }
<a name="l00122"></a>00122 
<a name="l00126"></a><a class="code" href="classturn_1_1StunAttrIterator.html#aac145186739b2185d4ce314df3f1cb7e">00126</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunAttrIterator.html#aac145186739b2185d4ce314df3f1cb7e">next</a>() throw(<a class="code" href="classturn_1_1EndOfStunMsgException.html">EndOfStunMsgException</a>) {
<a name="l00127"></a>00127                 <span class="keywordflow">if</span>(!_sar) {
<a name="l00128"></a>00128                         <span class="keywordflow">throw</span> EndOfStunMsgException();
<a name="l00129"></a>00129                 }
<a name="l00130"></a>00130                 _sar = <a class="code" href="ns__turn__msg_8h.html#a63699d8c20d5252c0eb94d8ad37e9d92">stun_attr_get_next_str</a>(_buf,_sz,_sar);
<a name="l00131"></a>00131         }
<a name="l00132"></a>00132 
<a name="l00136"></a><a class="code" href="classturn_1_1StunAttrIterator.html#ad6e5430541c401532ac9de0c24dda2f4">00136</a>         <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunAttrIterator.html#ad6e5430541c401532ac9de0c24dda2f4">eof</a>()<span class="keyword"> const </span>{
<a name="l00137"></a>00137                 <span class="keywordflow">return</span> (!_sar);
<a name="l00138"></a>00138         }
<a name="l00139"></a>00139 
<a name="l00143"></a><a class="code" href="classturn_1_1StunAttrIterator.html#a3b74d1b277340ec439fefdcdfdf0a40f">00143</a>         <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunAttrIterator.html#a3b74d1b277340ec439fefdcdfdf0a40f">isAddr</a>()<span class="keyword"> const </span>{
<a name="l00144"></a>00144                 <span class="keywordflow">return</span> <a class="code" href="ns__turn__msg_8h.html#a9a91835f95ce0fa295d8b9fbee9b98db">stun_attr_is_addr</a>(_sar);
<a name="l00145"></a>00145         }
<a name="l00146"></a>00146 
<a name="l00150"></a><a class="code" href="classturn_1_1StunAttrIterator.html#ad2ee2d3f6f2f46f53c43c5b49b1264a6">00150</a>         <span class="keywordtype">int</span> <a class="code" href="classturn_1_1StunAttrIterator.html#ad2ee2d3f6f2f46f53c43c5b49b1264a6">getAddressFamily</a>()<span class="keyword"> const </span>{
<a name="l00151"></a>00151                 <span class="keywordflow">return</span> <a class="code" href="ns__turn__msg_8h.html#a3f09dff5fdeccfbc47c7480cb6d3022b">stun_get_requested_address_family</a>(_sar);
<a name="l00152"></a>00152         }
<a name="l00153"></a>00153 
<a name="l00157"></a><a class="code" href="classturn_1_1StunAttrIterator.html#a7262021b86bdc21dd6b5dbc36456632c">00157</a>         <span class="keywordtype">int</span> <a class="code" href="classturn_1_1StunAttrIterator.html#a7262021b86bdc21dd6b5dbc36456632c">getType</a>()<span class="keyword"> const </span>{
<a name="l00158"></a>00158                 <span class="keywordflow">return</span> <a class="code" href="ns__turn__msg_8h.html#afe33b37ab65c1bca18377d50c88ff63b">stun_attr_get_type</a>(_sar);
<a name="l00159"></a>00159         }
<a name="l00160"></a>00160 
<a name="l00164"></a><a class="code" href="classturn_1_1StunAttrIterator.html#a4678eab1ddc3b4d54c9d45aa6f7122e4">00164</a>         <span class="keyword">virtual</span> <a class="code" href="classturn_1_1StunAttrIterator.html#a4678eab1ddc3b4d54c9d45aa6f7122e4">~StunAttrIterator</a>() {}
<a name="l00165"></a>00165 
<a name="l00170"></a><a class="code" href="classturn_1_1StunAttrIterator.html#af422c1b281075d182d406823b55f198d">00170</a>         <span class="keyword">const</span> u08bits *<a class="code" href="classturn_1_1StunAttrIterator.html#af422c1b281075d182d406823b55f198d">getRawBuffer</a>(<span class="keywordtype">size_t</span> &amp;sz) <span class="keyword">const</span> <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>) {
<a name="l00171"></a>00171                 <span class="keywordtype">int</span> len = <a class="code" href="ns__turn__msg_8h.html#a9abbba99b98eb81707300695ee51130e">stun_attr_get_len</a>(_sar);
<a name="l00172"></a>00172                 <span class="keywordflow">if</span>(len&lt;0)
<a name="l00173"></a>00173                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>();
<a name="l00174"></a>00174                 sz = (size_t)len;
<a name="l00175"></a>00175                 <span class="keyword">const</span> u08bits *value = <a class="code" href="ns__turn__msg_8h.html#af7fac8081f66d939f9f8211b88988678">stun_attr_get_value</a>(_sar);
<a name="l00176"></a>00176                 <span class="keywordflow">return</span> value;
<a name="l00177"></a>00177         }
<a name="l00178"></a><a class="code" href="classturn_1_1StunAttrIterator.html#a82f1cf551754f0ffb995484b693a5794">00178</a>         <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classturn_1_1StunAttr.html">StunAttr</a>;
<a name="l00179"></a>00179 <span class="keyword">private</span>:
<a name="l00180"></a>00180         u08bits *_buf;
<a name="l00181"></a>00181         <span class="keywordtype">size_t</span> _sz;
<a name="l00182"></a>00182         <a class="code" href="ns__turn__msg_8h.html#ad78e84b431d789f6799b3dabf786e032">stun_attr_ref</a> _sar;
<a name="l00183"></a>00183 };
<a name="l00184"></a>00184 
<a name="l00189"></a><a class="code" href="classturn_1_1StunAttr.html">00189</a> <span class="keyword">class </span><a class="code" href="classturn_1_1StunAttr.html">StunAttr</a> {
<a name="l00190"></a>00190 <span class="keyword">public</span>:
<a name="l00194"></a><a class="code" href="classturn_1_1StunAttr.html#aa31465ae7cf4f3664f8e30bc6f7bfb72">00194</a>         <a class="code" href="classturn_1_1StunAttr.html#aa31465ae7cf4f3664f8e30bc6f7bfb72">StunAttr</a>() : _attr_type(0), _value(0), _sz(0) {}
<a name="l00195"></a>00195 
<a name="l00199"></a><a class="code" href="classturn_1_1StunAttr.html#abaa18332f0ca717f9284f96e3595368f">00199</a>         <a class="code" href="classturn_1_1StunAttr.html#abaa18332f0ca717f9284f96e3595368f">StunAttr</a>(<span class="keyword">const</span> <a class="code" href="classturn_1_1StunAttrIterator.html">StunAttrIterator</a> &amp;iter) <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>, <a class="code" href="classturn_1_1EndOfStunMsgException.html">EndOfStunMsgException</a>) {
<a name="l00200"></a>00200                 <span class="keywordflow">if</span>(iter.eof()) {
<a name="l00201"></a>00201                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1EndOfStunMsgException.html">EndOfStunMsgException</a>();
<a name="l00202"></a>00202                 }
<a name="l00203"></a>00203                 <span class="keywordtype">size_t</span> sz = 0;
<a name="l00204"></a>00204                 <span class="keyword">const</span> u08bits *ptr = iter.getRawBuffer(sz);
<a name="l00205"></a>00205                 <span class="keywordflow">if</span>(sz&gt;=0xFFFF)
<a name="l00206"></a>00206                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>();
<a name="l00207"></a>00207                 <span class="keywordtype">int</span> at = iter.getType();
<a name="l00208"></a>00208                 <span class="keywordflow">if</span>(at&lt;0)
<a name="l00209"></a>00209                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>();
<a name="l00210"></a>00210                 _attr_type = (u16bits)at;
<a name="l00211"></a>00211                 _sz = sz;
<a name="l00212"></a>00212                 _value=(u08bits*)turn_malloc(_sz);
<a name="l00213"></a>00213                 <span class="keywordflow">if</span>(ptr)
<a name="l00214"></a>00214                         ns_bcopy(ptr,_value,_sz);
<a name="l00215"></a>00215         }
<a name="l00216"></a>00216 
<a name="l00220"></a><a class="code" href="classturn_1_1StunAttr.html#a4c0c6e6932d150bacfe7809b9d86414d">00220</a>         <span class="keyword">virtual</span> <a class="code" href="classturn_1_1StunAttr.html#a4c0c6e6932d150bacfe7809b9d86414d">~StunAttr</a>() {
<a name="l00221"></a>00221                 <span class="keywordflow">if</span>(_value)
<a name="l00222"></a>00222                         turn_free(_value,_sz);
<a name="l00223"></a>00223         }
<a name="l00224"></a>00224 
<a name="l00228"></a><a class="code" href="classturn_1_1StunAttr.html#aa3d87060e2c64d41727889ca3c7bccba">00228</a>         <span class="keyword">const</span> u08bits *<a class="code" href="classturn_1_1StunAttr.html#aa3d87060e2c64d41727889ca3c7bccba">getRawValue</a>(<span class="keywordtype">size_t</span> &amp;sz)<span class="keyword"> const </span>{
<a name="l00229"></a>00229                 sz=_sz;
<a name="l00230"></a>00230                 <span class="keywordflow">return</span> _value;
<a name="l00231"></a>00231         }
<a name="l00232"></a>00232 
<a name="l00236"></a><a class="code" href="classturn_1_1StunAttr.html#a53f4ac3bbad98840a540b0cb9fd0b702">00236</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunAttr.html#a53f4ac3bbad98840a540b0cb9fd0b702">setRawValue</a>(u08bits *value, <span class="keywordtype">size_t</span> sz) <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>) {
<a name="l00237"></a>00237                 <span class="keywordflow">if</span>(sz&gt;0xFFFF)
<a name="l00238"></a>00238                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>();
<a name="l00239"></a>00239                 <span class="keywordflow">if</span>(_value)
<a name="l00240"></a>00240                         turn_free(_value,_sz);
<a name="l00241"></a>00241                 _sz = sz;
<a name="l00242"></a>00242                 _value=(u08bits*)turn_malloc(_sz);
<a name="l00243"></a>00243                 <span class="keywordflow">if</span>(value)
<a name="l00244"></a>00244                         ns_bcopy(value,_value,_sz);
<a name="l00245"></a>00245         }
<a name="l00246"></a>00246 
<a name="l00250"></a><a class="code" href="classturn_1_1StunAttr.html#a17596ddd85176f2fe14b9ef2ccdd4640">00250</a>         u16bits <a class="code" href="classturn_1_1StunAttr.html#a17596ddd85176f2fe14b9ef2ccdd4640">getType</a>()<span class="keyword"> const </span>{
<a name="l00251"></a>00251                 <span class="keywordflow">return</span> _attr_type;
<a name="l00252"></a>00252         }
<a name="l00253"></a>00253 
<a name="l00257"></a><a class="code" href="classturn_1_1StunAttr.html#a3b4c326f288d2a0b1b7288db573eef92">00257</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunAttr.html#a3b4c326f288d2a0b1b7288db573eef92">setType</a>(u16bits at) {
<a name="l00258"></a>00258                 _attr_type = at;
<a name="l00259"></a>00259         }
<a name="l00260"></a>00260 
<a name="l00264"></a>00264         <span class="keyword">template</span>&lt;<span class="keyword">class</span> T&gt;
<a name="l00265"></a><a class="code" href="classturn_1_1StunAttr.html#aab1f7b44700245718baa1fb12169ac90">00265</a>         <span class="keywordtype">int</span> <a class="code" href="classturn_1_1StunAttr.html#aab1f7b44700245718baa1fb12169ac90">addToMsg</a>(T &amp;msg) <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>, <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) {
<a name="l00266"></a>00266                 <span class="keywordflow">if</span>(!_attr_type)
<a name="l00267"></a>00267                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>();
<a name="l00268"></a>00268                 u08bits *buffer = msg.getRawBuffer();
<a name="l00269"></a>00269                 <span class="keywordflow">if</span>(buffer) {
<a name="l00270"></a>00270                         <span class="keywordtype">size_t</span> sz = msg.getSize();
<a name="l00271"></a>00271                         <span class="keywordflow">if</span>(<a class="code" href="classturn_1_1StunAttr.html#ac0e3317f4db852b848ed156e14e38134">addToBuffer</a>(buffer, sz)&lt;0) {
<a name="l00272"></a>00272                                 <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>();
<a name="l00273"></a>00273                         }
<a name="l00274"></a>00274                         msg.setSize(sz);
<a name="l00275"></a>00275                         <span class="keywordflow">return</span> 0;
<a name="l00276"></a>00276                 }
<a name="l00277"></a>00277                 <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>();
<a name="l00278"></a>00278         }
<a name="l00279"></a>00279 <span class="keyword">protected</span>:
<a name="l00280"></a>00280 
<a name="l00284"></a><a class="code" href="classturn_1_1StunAttr.html#ac0e3317f4db852b848ed156e14e38134">00284</a>         <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classturn_1_1StunAttr.html#ac0e3317f4db852b848ed156e14e38134">addToBuffer</a>(u08bits *buffer, <span class="keywordtype">size_t</span> &amp;sz) <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>, <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) {
<a name="l00285"></a>00285                 <span class="keywordflow">if</span>(buffer) {
<a name="l00286"></a>00286                         <span class="keywordflow">if</span>(!_value)
<a name="l00287"></a>00287                                 <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>();
<a name="l00288"></a>00288                         <span class="keywordflow">if</span>(<a class="code" href="ns__turn__msg_8h.html#a66ee2e33b2311217a586165c02a6507b">stun_attr_add_str</a>(buffer, &amp;sz, _attr_type, _value, _sz)&lt;0) {
<a name="l00289"></a>00289                                 <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>();
<a name="l00290"></a>00290                         }
<a name="l00291"></a>00291                         <span class="keywordflow">return</span> 0;
<a name="l00292"></a>00292                 }
<a name="l00293"></a>00293                 <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>();
<a name="l00294"></a>00294         }
<a name="l00295"></a>00295 
<a name="l00299"></a><a class="code" href="classturn_1_1StunAttr.html#a2d7219513d0a946907b0a2402132ddff">00299</a>         <span class="keyword">static</span> <a class="code" href="ns__turn__msg_8h.html#ad78e84b431d789f6799b3dabf786e032">stun_attr_ref</a> <a class="code" href="classturn_1_1StunAttr.html#a2d7219513d0a946907b0a2402132ddff">getSar</a>(<span class="keyword">const</span> <a class="code" href="classturn_1_1StunAttrIterator.html">StunAttrIterator</a> &amp;iter) {
<a name="l00300"></a>00300                 <span class="keywordflow">return</span> iter._sar;
<a name="l00301"></a>00301         }
<a name="l00302"></a>00302 <span class="keyword">private</span>:
<a name="l00303"></a>00303         u16bits _attr_type;
<a name="l00304"></a>00304         u08bits *_value;
<a name="l00305"></a>00305         <span class="keywordtype">size_t</span> _sz;
<a name="l00306"></a>00306 };
<a name="l00307"></a>00307 
<a name="l00311"></a><a class="code" href="classturn_1_1StunAttrChannelNumber.html">00311</a> <span class="keyword">class </span><a class="code" href="classturn_1_1StunAttrChannelNumber.html">StunAttrChannelNumber</a> : <span class="keyword">public</span> <a class="code" href="classturn_1_1StunAttr.html">StunAttr</a> {
<a name="l00312"></a>00312 <span class="keyword">public</span>:
<a name="l00313"></a><a class="code" href="classturn_1_1StunAttrChannelNumber.html#a3befbd7835f4ac55d39748964f1409a3">00313</a>         <a class="code" href="classturn_1_1StunAttrChannelNumber.html#a3befbd7835f4ac55d39748964f1409a3">StunAttrChannelNumber</a>() : _cn(0) {
<a name="l00314"></a>00314                 <a class="code" href="classturn_1_1StunAttr.html#a3b4c326f288d2a0b1b7288db573eef92">setType</a>(STUN_ATTRIBUTE_CHANNEL_NUMBER);
<a name="l00315"></a>00315         }
<a name="l00316"></a><a class="code" href="classturn_1_1StunAttrChannelNumber.html#af46beabd47335023083bdd35b5101e28">00316</a>         <a class="code" href="classturn_1_1StunAttrChannelNumber.html#a3befbd7835f4ac55d39748964f1409a3">StunAttrChannelNumber</a>(<span class="keyword">const</span> <a class="code" href="classturn_1_1StunAttrIterator.html">StunAttrIterator</a> &amp;iter)
<a name="l00317"></a>00317                 <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>, <a class="code" href="classturn_1_1EndOfStunMsgException.html">EndOfStunMsgException</a>) :
<a name="l00318"></a>00318                 <a class="code" href="classturn_1_1StunAttr.html#aa31465ae7cf4f3664f8e30bc6f7bfb72">StunAttr</a>(iter) {
<a name="l00319"></a>00319 
<a name="l00320"></a>00320                 <span class="keywordflow">if</span>(iter.eof())
<a name="l00321"></a>00321                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1EndOfStunMsgException.html">EndOfStunMsgException</a>();
<a name="l00322"></a>00322                 _cn = <a class="code" href="ns__turn__msg_8h.html#a6a51a99d0883abefba30099d4c9b22bc">stun_attr_get_channel_number</a>(<a class="code" href="classturn_1_1StunAttr.html#a2d7219513d0a946907b0a2402132ddff">getSar</a>(iter));
<a name="l00323"></a>00323                 <span class="keywordflow">if</span>(!_cn)
<a name="l00324"></a>00324                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>();
<a name="l00325"></a>00325         }
<a name="l00326"></a><a class="code" href="classturn_1_1StunAttrChannelNumber.html#ac1750a094ef6c16b9b096a9d9d733622">00326</a>         <span class="keyword">virtual</span> <a class="code" href="classturn_1_1StunAttrChannelNumber.html#ac1750a094ef6c16b9b096a9d9d733622">~StunAttrChannelNumber</a>() {}
<a name="l00327"></a><a class="code" href="classturn_1_1StunAttrChannelNumber.html#a3b981f580590265159ee644452e7a757">00327</a>         u16bits <a class="code" href="classturn_1_1StunAttrChannelNumber.html#a3b981f580590265159ee644452e7a757">getChannelNumber</a>()<span class="keyword"> const </span>{
<a name="l00328"></a>00328                 <span class="keywordflow">return</span> _cn;
<a name="l00329"></a>00329         }
<a name="l00330"></a><a class="code" href="classturn_1_1StunAttrChannelNumber.html#a8a7c8616d28b3682692b229bab3c27db">00330</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunAttrChannelNumber.html#a8a7c8616d28b3682692b229bab3c27db">setChannelNumber</a>(u16bits cn) {
<a name="l00331"></a>00331                 _cn = cn;
<a name="l00332"></a>00332         }
<a name="l00333"></a>00333 <span class="keyword">protected</span>:
<a name="l00334"></a><a class="code" href="classturn_1_1StunAttrChannelNumber.html#a5c99a52e89ce041f30df43857f4b86fd">00334</a>         <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classturn_1_1StunAttrChannelNumber.html#a5c99a52e89ce041f30df43857f4b86fd">addToBuffer</a>(u08bits *buffer, <span class="keywordtype">size_t</span> &amp;sz) <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>, <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) {
<a name="l00335"></a>00335                 <span class="keywordflow">return</span> <a class="code" href="ns__turn__msg_8h.html#ae412f474395bab66f57c1bab62f93a93">stun_attr_add_channel_number_str</a>(buffer,&amp;sz,_cn);
<a name="l00336"></a>00336         }
<a name="l00337"></a>00337 <span class="keyword">private</span>:
<a name="l00338"></a>00338         u16bits _cn;
<a name="l00339"></a>00339 };
<a name="l00340"></a>00340 
<a name="l00344"></a><a class="code" href="classturn_1_1StunAttrEvenPort.html">00344</a> <span class="keyword">class </span><a class="code" href="classturn_1_1StunAttrEvenPort.html">StunAttrEvenPort</a> : <span class="keyword">public</span> <a class="code" href="classturn_1_1StunAttr.html">StunAttr</a> {
<a name="l00345"></a>00345 <span class="keyword">public</span>:
<a name="l00346"></a><a class="code" href="classturn_1_1StunAttrEvenPort.html#aa607c9094262c3f1a5353c78de08f122">00346</a>         <a class="code" href="classturn_1_1StunAttrEvenPort.html#aa607c9094262c3f1a5353c78de08f122">StunAttrEvenPort</a>() : _ep(0) {
<a name="l00347"></a>00347                 <a class="code" href="classturn_1_1StunAttr.html#a3b4c326f288d2a0b1b7288db573eef92">setType</a>(STUN_ATTRIBUTE_EVEN_PORT);
<a name="l00348"></a>00348         }
<a name="l00349"></a><a class="code" href="classturn_1_1StunAttrEvenPort.html#aa264a97fbf882a61a4e1967be533fdb0">00349</a>         <a class="code" href="classturn_1_1StunAttrEvenPort.html#aa607c9094262c3f1a5353c78de08f122">StunAttrEvenPort</a>(<span class="keyword">const</span> <a class="code" href="classturn_1_1StunAttrIterator.html">StunAttrIterator</a> &amp;iter)
<a name="l00350"></a>00350                 <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>, <a class="code" href="classturn_1_1EndOfStunMsgException.html">EndOfStunMsgException</a>) :
<a name="l00351"></a>00351                 <a class="code" href="classturn_1_1StunAttr.html#aa31465ae7cf4f3664f8e30bc6f7bfb72">StunAttr</a>(iter) {
<a name="l00352"></a>00352 
<a name="l00353"></a>00353                 <span class="keywordflow">if</span>(iter.eof())
<a name="l00354"></a>00354                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1EndOfStunMsgException.html">EndOfStunMsgException</a>();
<a name="l00355"></a>00355                 _ep = <a class="code" href="ns__turn__msg_8h.html#a179a2c9747c8d56cb9b1fe24f323d152">stun_attr_get_even_port</a>(<a class="code" href="classturn_1_1StunAttr.html#a2d7219513d0a946907b0a2402132ddff">getSar</a>(iter));
<a name="l00356"></a>00356         }
<a name="l00357"></a><a class="code" href="classturn_1_1StunAttrEvenPort.html#a0b357a73b2818adff40270ea22363681">00357</a>         <span class="keyword">virtual</span> <a class="code" href="classturn_1_1StunAttrEvenPort.html#a0b357a73b2818adff40270ea22363681">~StunAttrEvenPort</a>() {}
<a name="l00358"></a><a class="code" href="classturn_1_1StunAttrEvenPort.html#afb10b113a41051815b757df80ada10ec">00358</a>         u08bits <a class="code" href="classturn_1_1StunAttrEvenPort.html#afb10b113a41051815b757df80ada10ec">getEvenPort</a>()<span class="keyword"> const </span>{
<a name="l00359"></a>00359                 <span class="keywordflow">return</span> _ep;
<a name="l00360"></a>00360         }
<a name="l00361"></a><a class="code" href="classturn_1_1StunAttrEvenPort.html#ab2b69aada2971f1875cbf5d1b7498a4b">00361</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunAttrEvenPort.html#ab2b69aada2971f1875cbf5d1b7498a4b">setEvenPort</a>(u08bits ep) {
<a name="l00362"></a>00362                 _ep = ep;
<a name="l00363"></a>00363         }
<a name="l00364"></a>00364 <span class="keyword">protected</span>:
<a name="l00365"></a><a class="code" href="classturn_1_1StunAttrEvenPort.html#aa88c8a9d6f5c5d72e228fee45cb1b298">00365</a>         <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classturn_1_1StunAttrEvenPort.html#aa88c8a9d6f5c5d72e228fee45cb1b298">addToBuffer</a>(u08bits *buffer, <span class="keywordtype">size_t</span> &amp;sz) <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>, <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) {
<a name="l00366"></a>00366                 <span class="keywordflow">return</span> <a class="code" href="ns__turn__msg_8h.html#a66ee2e33b2311217a586165c02a6507b">stun_attr_add_str</a>(buffer, &amp;sz, STUN_ATTRIBUTE_EVEN_PORT, &amp;_ep, 1);
<a name="l00367"></a>00367         }
<a name="l00368"></a>00368 <span class="keyword">private</span>:
<a name="l00369"></a>00369         u08bits _ep;
<a name="l00370"></a>00370 };
<a name="l00371"></a>00371 
<a name="l00375"></a><a class="code" href="classturn_1_1StunAttrReservationToken.html">00375</a> <span class="keyword">class </span><a class="code" href="classturn_1_1StunAttrReservationToken.html">StunAttrReservationToken</a> : <span class="keyword">public</span> <a class="code" href="classturn_1_1StunAttr.html">StunAttr</a> {
<a name="l00376"></a>00376 <span class="keyword">public</span>:
<a name="l00377"></a><a class="code" href="classturn_1_1StunAttrReservationToken.html#aa1a71c7ee11c86ba1a02987a4be9c58f">00377</a>         <a class="code" href="classturn_1_1StunAttrReservationToken.html#aa1a71c7ee11c86ba1a02987a4be9c58f">StunAttrReservationToken</a>() : _rt(0) {
<a name="l00378"></a>00378                 <a class="code" href="classturn_1_1StunAttr.html#a3b4c326f288d2a0b1b7288db573eef92">setType</a>(STUN_ATTRIBUTE_RESERVATION_TOKEN);
<a name="l00379"></a>00379         }
<a name="l00380"></a><a class="code" href="classturn_1_1StunAttrReservationToken.html#ac2296024aa6d23e33771652aa0411703">00380</a>         <a class="code" href="classturn_1_1StunAttrReservationToken.html#aa1a71c7ee11c86ba1a02987a4be9c58f">StunAttrReservationToken</a>(<span class="keyword">const</span> <a class="code" href="classturn_1_1StunAttrIterator.html">StunAttrIterator</a> &amp;iter)
<a name="l00381"></a>00381                 <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>, <a class="code" href="classturn_1_1EndOfStunMsgException.html">EndOfStunMsgException</a>) :
<a name="l00382"></a>00382                 <a class="code" href="classturn_1_1StunAttr.html#aa31465ae7cf4f3664f8e30bc6f7bfb72">StunAttr</a>(iter) {
<a name="l00383"></a>00383 
<a name="l00384"></a>00384                 <span class="keywordflow">if</span>(iter.eof())
<a name="l00385"></a>00385                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1EndOfStunMsgException.html">EndOfStunMsgException</a>();
<a name="l00386"></a>00386                 _rt = <a class="code" href="ns__turn__msg_8h.html#a9d262ce740ed097be15d47c3ca050d67">stun_attr_get_reservation_token_value</a>(<a class="code" href="classturn_1_1StunAttr.html#a2d7219513d0a946907b0a2402132ddff">getSar</a>(iter));
<a name="l00387"></a>00387         }
<a name="l00388"></a><a class="code" href="classturn_1_1StunAttrReservationToken.html#ae577d4010adc0be05433c3c7aa06789e">00388</a>         <span class="keyword">virtual</span> <a class="code" href="classturn_1_1StunAttrReservationToken.html#ae577d4010adc0be05433c3c7aa06789e">~StunAttrReservationToken</a>() {}
<a name="l00389"></a><a class="code" href="classturn_1_1StunAttrReservationToken.html#a610a1fe9fd331148bc9c07a62e117819">00389</a>         u64bits <a class="code" href="classturn_1_1StunAttrReservationToken.html#a610a1fe9fd331148bc9c07a62e117819">getReservationToken</a>()<span class="keyword"> const </span>{
<a name="l00390"></a>00390                 <span class="keywordflow">return</span> _rt;
<a name="l00391"></a>00391         }
<a name="l00392"></a><a class="code" href="classturn_1_1StunAttrReservationToken.html#a4077eb38e9607b5dd98d5f03adbb5c16">00392</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunAttrReservationToken.html#a4077eb38e9607b5dd98d5f03adbb5c16">setReservationToken</a>(u64bits rt) {
<a name="l00393"></a>00393                 _rt = rt;
<a name="l00394"></a>00394         }
<a name="l00395"></a>00395 <span class="keyword">protected</span>:
<a name="l00396"></a><a class="code" href="classturn_1_1StunAttrReservationToken.html#a102c8acb5c9a7b0f17fe25063769d4af">00396</a>         <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classturn_1_1StunAttrReservationToken.html#a102c8acb5c9a7b0f17fe25063769d4af">addToBuffer</a>(u08bits *buffer, <span class="keywordtype">size_t</span> &amp;sz) <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>, <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) {
<a name="l00397"></a>00397                 uint64_t reservation_token = ioa_ntoh64(_rt);
<a name="l00398"></a>00398                 <span class="keywordflow">return</span> <a class="code" href="ns__turn__msg_8h.html#a66ee2e33b2311217a586165c02a6507b">stun_attr_add_str</a>(buffer, &amp;sz, STUN_ATTRIBUTE_RESERVATION_TOKEN, (u08bits*) (&amp;reservation_token), 8);
<a name="l00399"></a>00399         }
<a name="l00400"></a>00400 <span class="keyword">private</span>:
<a name="l00401"></a>00401         u64bits _rt;
<a name="l00402"></a>00402 };
<a name="l00403"></a>00403 
<a name="l00407"></a><a class="code" href="classturn_1_1StunAttrAddr.html">00407</a> <span class="keyword">class </span><a class="code" href="classturn_1_1StunAttrAddr.html">StunAttrAddr</a> : <span class="keyword">public</span> <a class="code" href="classturn_1_1StunAttr.html">StunAttr</a> {
<a name="l00408"></a>00408 <span class="keyword">public</span>:
<a name="l00409"></a><a class="code" href="classturn_1_1StunAttrAddr.html#a97b7b3549970d03d9a7b37c6b393f786">00409</a>         <a class="code" href="classturn_1_1StunAttrAddr.html#a97b7b3549970d03d9a7b37c6b393f786">StunAttrAddr</a>(u16bits attr_type = 0) {
<a name="l00410"></a>00410                 addr_set_any(&amp;_addr);
<a name="l00411"></a>00411                 <a class="code" href="classturn_1_1StunAttr.html#a3b4c326f288d2a0b1b7288db573eef92">setType</a>(attr_type);
<a name="l00412"></a>00412         }
<a name="l00413"></a><a class="code" href="classturn_1_1StunAttrAddr.html#a7d527a5650c949e333a2e0fd7e426884">00413</a>         <a class="code" href="classturn_1_1StunAttrAddr.html#a97b7b3549970d03d9a7b37c6b393f786">StunAttrAddr</a>(<span class="keyword">const</span> <a class="code" href="classturn_1_1StunAttrIterator.html">StunAttrIterator</a> &amp;iter)
<a name="l00414"></a>00414                 <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>, <a class="code" href="classturn_1_1EndOfStunMsgException.html">EndOfStunMsgException</a>) :
<a name="l00415"></a>00415                 <a class="code" href="classturn_1_1StunAttr.html#aa31465ae7cf4f3664f8e30bc6f7bfb72">StunAttr</a>(iter) {
<a name="l00416"></a>00416 
<a name="l00417"></a>00417                 <span class="keywordflow">if</span>(iter.eof())
<a name="l00418"></a>00418                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1EndOfStunMsgException.html">EndOfStunMsgException</a>();
<a name="l00419"></a>00419                 <span class="keywordtype">size_t</span> sz = 0;
<a name="l00420"></a>00420                 <span class="keyword">const</span> u08bits *buf = iter.getRawBuffer(sz);
<a name="l00421"></a>00421                 <span class="keywordflow">if</span>(<a class="code" href="ns__turn__msg_8h.html#a84c87146057884663541eb75cf39853f">stun_attr_get_addr_str</a>(buf,sz,<a class="code" href="classturn_1_1StunAttr.html#a2d7219513d0a946907b0a2402132ddff">getSar</a>(iter),&amp;_addr,NULL)&lt;0) {
<a name="l00422"></a>00422                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>();
<a name="l00423"></a>00423                 }
<a name="l00424"></a>00424         }
<a name="l00425"></a><a class="code" href="classturn_1_1StunAttrAddr.html#a12aa4455d35f01291bdf3824efe9efa2">00425</a>         <span class="keyword">virtual</span> <a class="code" href="classturn_1_1StunAttrAddr.html#a12aa4455d35f01291bdf3824efe9efa2">~StunAttrAddr</a>() {}
<a name="l00426"></a><a class="code" href="classturn_1_1StunAttrAddr.html#a13433dfa48a4e03277d2edb04d29aacc">00426</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunAttrAddr.html#a13433dfa48a4e03277d2edb04d29aacc">getAddr</a>(ioa_addr &amp;addr)<span class="keyword"> const </span>{
<a name="l00427"></a>00427                 addr_cpy(&amp;addr,&amp;_addr);
<a name="l00428"></a>00428         }
<a name="l00429"></a><a class="code" href="classturn_1_1StunAttrAddr.html#a5894530b4517544d7b4e8eb8bfe7e8cd">00429</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunAttrAddr.html#a5894530b4517544d7b4e8eb8bfe7e8cd">setAddr</a>(ioa_addr &amp;addr) {
<a name="l00430"></a>00430                 addr_cpy(&amp;_addr,&amp;addr);
<a name="l00431"></a>00431         }
<a name="l00432"></a>00432 <span class="keyword">protected</span>:
<a name="l00433"></a><a class="code" href="classturn_1_1StunAttrAddr.html#afd54e3d2f0f8a6812b5a6803377a603b">00433</a>         <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classturn_1_1StunAttrAddr.html#afd54e3d2f0f8a6812b5a6803377a603b">addToBuffer</a>(u08bits *buffer, <span class="keywordtype">size_t</span> &amp;sz) <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>, <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) {
<a name="l00434"></a>00434                 <span class="keywordflow">return</span> <a class="code" href="ns__turn__msg_8h.html#aa61aa5b56c7b248208d654065d0faa57">stun_attr_add_addr_str</a>(buffer, &amp;sz, <a class="code" href="classturn_1_1StunAttr.html#a17596ddd85176f2fe14b9ef2ccdd4640">getType</a>(), &amp;_addr);
<a name="l00435"></a>00435         }
<a name="l00436"></a>00436 <span class="keyword">private</span>:
<a name="l00437"></a>00437         ioa_addr _addr;
<a name="l00438"></a>00438 };
<a name="l00439"></a>00439 
<a name="l00443"></a><a class="code" href="classturn_1_1StunAttrChangeRequest.html">00443</a> <span class="keyword">class </span><a class="code" href="classturn_1_1StunAttrChangeRequest.html">StunAttrChangeRequest</a> : <span class="keyword">public</span> <a class="code" href="classturn_1_1StunAttr.html">StunAttr</a> {
<a name="l00444"></a>00444 <span class="keyword">public</span>:
<a name="l00445"></a><a class="code" href="classturn_1_1StunAttrChangeRequest.html#a133242c6ac23a812ef3b44b4b571135d">00445</a>         <a class="code" href="classturn_1_1StunAttrChangeRequest.html#a133242c6ac23a812ef3b44b4b571135d">StunAttrChangeRequest</a>() : _changeIp(0), _changePort(0) {
<a name="l00446"></a>00446                 <a class="code" href="classturn_1_1StunAttr.html#a3b4c326f288d2a0b1b7288db573eef92">setType</a>(STUN_ATTRIBUTE_CHANGE_REQUEST);
<a name="l00447"></a>00447         }
<a name="l00448"></a><a class="code" href="classturn_1_1StunAttrChangeRequest.html#a560e6fa6ce129b3a7059e49d057352c4">00448</a>         <a class="code" href="classturn_1_1StunAttrChangeRequest.html#a133242c6ac23a812ef3b44b4b571135d">StunAttrChangeRequest</a>(<span class="keyword">const</span> <a class="code" href="classturn_1_1StunAttrIterator.html">StunAttrIterator</a> &amp;iter)
<a name="l00449"></a>00449                 <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>, <a class="code" href="classturn_1_1EndOfStunMsgException.html">EndOfStunMsgException</a>) :
<a name="l00450"></a>00450                 <a class="code" href="classturn_1_1StunAttr.html#aa31465ae7cf4f3664f8e30bc6f7bfb72">StunAttr</a>(iter) {
<a name="l00451"></a>00451 
<a name="l00452"></a>00452                 <span class="keywordflow">if</span>(iter.eof())
<a name="l00453"></a>00453                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1EndOfStunMsgException.html">EndOfStunMsgException</a>();
<a name="l00454"></a>00454 
<a name="l00455"></a>00455                 <span class="keywordflow">if</span>(<a class="code" href="ns__turn__msg_8h.html#ab1d5f565d07e838005d1c786805308a9">stun_attr_get_change_request_str</a>(<a class="code" href="classturn_1_1StunAttr.html#a2d7219513d0a946907b0a2402132ddff">getSar</a>(iter), &amp;_changeIp, &amp;_changePort)&lt;0) {
<a name="l00456"></a>00456                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>();
<a name="l00457"></a>00457                 }
<a name="l00458"></a>00458         }
<a name="l00459"></a><a class="code" href="classturn_1_1StunAttrChangeRequest.html#a802d9cc43ea72166dd879ae89d846936">00459</a>         <span class="keyword">virtual</span> <a class="code" href="classturn_1_1StunAttrChangeRequest.html#a802d9cc43ea72166dd879ae89d846936">~StunAttrChangeRequest</a>() {}
<a name="l00460"></a><a class="code" href="classturn_1_1StunAttrChangeRequest.html#a606046ab8f2c4c57e37648774e98f959">00460</a>         <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunAttrChangeRequest.html#a606046ab8f2c4c57e37648774e98f959">getChangeIp</a>()<span class="keyword"> const </span>{
<a name="l00461"></a>00461                 <span class="keywordflow">return</span> _changeIp;
<a name="l00462"></a>00462         }
<a name="l00463"></a><a class="code" href="classturn_1_1StunAttrChangeRequest.html#aebc116e82355ab6c7f2de9cb57b8a553">00463</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunAttrChangeRequest.html#aebc116e82355ab6c7f2de9cb57b8a553">setChangeIp</a>(<span class="keywordtype">bool</span> ci) {
<a name="l00464"></a>00464                 <span class="keywordflow">if</span>(ci)
<a name="l00465"></a>00465                         _changeIp = 1;
<a name="l00466"></a>00466                 <span class="keywordflow">else</span>
<a name="l00467"></a>00467                         _changeIp = 0;
<a name="l00468"></a>00468         }
<a name="l00469"></a><a class="code" href="classturn_1_1StunAttrChangeRequest.html#ad2f65fc003d8e4e7b651768aa95f4da9">00469</a>         <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunAttrChangeRequest.html#ad2f65fc003d8e4e7b651768aa95f4da9">getChangePort</a>()<span class="keyword"> const </span>{
<a name="l00470"></a>00470                 <span class="keywordflow">return</span> _changePort;
<a name="l00471"></a>00471         }
<a name="l00472"></a><a class="code" href="classturn_1_1StunAttrChangeRequest.html#a09964f9d51ca382ae7a2ef64d25f599f">00472</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunAttrChangeRequest.html#a09964f9d51ca382ae7a2ef64d25f599f">setChangePort</a>(<span class="keywordtype">bool</span> cp) {
<a name="l00473"></a>00473                 <span class="keywordflow">if</span>(cp)
<a name="l00474"></a>00474                         _changePort = 1;
<a name="l00475"></a>00475                 <span class="keywordflow">else</span>
<a name="l00476"></a>00476                         _changePort = 0;
<a name="l00477"></a>00477         }
<a name="l00478"></a>00478 <span class="keyword">protected</span>:
<a name="l00479"></a><a class="code" href="classturn_1_1StunAttrChangeRequest.html#a166da020f6b0c12b3f833f4841acdde9">00479</a>         <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classturn_1_1StunAttrChangeRequest.html#a166da020f6b0c12b3f833f4841acdde9">addToBuffer</a>(u08bits *buffer, <span class="keywordtype">size_t</span> &amp;sz) <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>, <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) {
<a name="l00480"></a>00480                 <span class="keywordflow">return</span> <a class="code" href="ns__turn__msg_8h.html#ae2cf75a0daddd2ed18e40350be449976">stun_attr_add_change_request_str</a>(buffer, &amp;sz, _changeIp, _changePort);
<a name="l00481"></a>00481         }
<a name="l00482"></a>00482 <span class="keyword">private</span>:
<a name="l00483"></a>00483         <span class="keywordtype">int</span> _changeIp;
<a name="l00484"></a>00484         <span class="keywordtype">int</span> _changePort;
<a name="l00485"></a>00485 };
<a name="l00486"></a>00486 
<a name="l00490"></a><a class="code" href="classturn_1_1StunAttrResponsePort.html">00490</a> <span class="keyword">class </span><a class="code" href="classturn_1_1StunAttrResponsePort.html">StunAttrResponsePort</a> : <span class="keyword">public</span> <a class="code" href="classturn_1_1StunAttr.html">StunAttr</a> {
<a name="l00491"></a>00491 <span class="keyword">public</span>:
<a name="l00492"></a><a class="code" href="classturn_1_1StunAttrResponsePort.html#af3246bd579cacf3ed68e16d3ff9124ff">00492</a>         <a class="code" href="classturn_1_1StunAttrResponsePort.html#af3246bd579cacf3ed68e16d3ff9124ff">StunAttrResponsePort</a>() : _rp(0) {
<a name="l00493"></a>00493                 <a class="code" href="classturn_1_1StunAttr.html#a3b4c326f288d2a0b1b7288db573eef92">setType</a>(STUN_ATTRIBUTE_RESPONSE_PORT);
<a name="l00494"></a>00494         }
<a name="l00495"></a><a class="code" href="classturn_1_1StunAttrResponsePort.html#ac1857e1cec3ba8344e45b26cde2d31d4">00495</a>         <a class="code" href="classturn_1_1StunAttrResponsePort.html#af3246bd579cacf3ed68e16d3ff9124ff">StunAttrResponsePort</a>(<span class="keyword">const</span> <a class="code" href="classturn_1_1StunAttrIterator.html">StunAttrIterator</a> &amp;iter)
<a name="l00496"></a>00496                 <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>, <a class="code" href="classturn_1_1EndOfStunMsgException.html">EndOfStunMsgException</a>) :
<a name="l00497"></a>00497                 <a class="code" href="classturn_1_1StunAttr.html#aa31465ae7cf4f3664f8e30bc6f7bfb72">StunAttr</a>(iter) {
<a name="l00498"></a>00498 
<a name="l00499"></a>00499                 <span class="keywordflow">if</span>(iter.eof())
<a name="l00500"></a>00500                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1EndOfStunMsgException.html">EndOfStunMsgException</a>();
<a name="l00501"></a>00501 
<a name="l00502"></a>00502                 <span class="keywordtype">int</span> rp = <a class="code" href="ns__turn__msg_8h.html#a21b8ee9859eb6f397b8d4e4ed2aff68f">stun_attr_get_response_port_str</a>(<a class="code" href="classturn_1_1StunAttr.html#a2d7219513d0a946907b0a2402132ddff">getSar</a>(iter));
<a name="l00503"></a>00503                 <span class="keywordflow">if</span>(rp&lt;0) {
<a name="l00504"></a>00504                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>();
<a name="l00505"></a>00505                 }
<a name="l00506"></a>00506                 _rp = (u16bits)rp;
<a name="l00507"></a>00507         }
<a name="l00508"></a><a class="code" href="classturn_1_1StunAttrResponsePort.html#a690fb8a524a92b5488cb6f06a320692b">00508</a>         <span class="keyword">virtual</span> <a class="code" href="classturn_1_1StunAttrResponsePort.html#a690fb8a524a92b5488cb6f06a320692b">~StunAttrResponsePort</a>() {}
<a name="l00509"></a><a class="code" href="classturn_1_1StunAttrResponsePort.html#aeb376a27627910cbd751576fdc27d288">00509</a>         u16bits <a class="code" href="classturn_1_1StunAttrResponsePort.html#aeb376a27627910cbd751576fdc27d288">getResponsePort</a>()<span class="keyword"> const </span>{
<a name="l00510"></a>00510                 <span class="keywordflow">return</span> _rp;
<a name="l00511"></a>00511         }
<a name="l00512"></a><a class="code" href="classturn_1_1StunAttrResponsePort.html#abac5da52b698dc7769257aa5eb03aef5">00512</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunAttrResponsePort.html#abac5da52b698dc7769257aa5eb03aef5">setResponsePort</a>(u16bits p) {
<a name="l00513"></a>00513                 _rp = p;
<a name="l00514"></a>00514         }
<a name="l00515"></a>00515 <span class="keyword">protected</span>:
<a name="l00516"></a><a class="code" href="classturn_1_1StunAttrResponsePort.html#a6360780c7dc8fc596ce0bab436a98269">00516</a>         <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classturn_1_1StunAttrResponsePort.html#a6360780c7dc8fc596ce0bab436a98269">addToBuffer</a>(u08bits *buffer, <span class="keywordtype">size_t</span> &amp;sz) <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>, <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) {
<a name="l00517"></a>00517                 <span class="keywordflow">return</span> <a class="code" href="ns__turn__msg_8h.html#a6f59cb8291dc5fe1a524a13147938a48">stun_attr_add_response_port_str</a>(buffer, &amp;sz, _rp);
<a name="l00518"></a>00518         }
<a name="l00519"></a>00519 <span class="keyword">private</span>:
<a name="l00520"></a>00520         u16bits _rp;
<a name="l00521"></a>00521 };
<a name="l00522"></a>00522 
<a name="l00526"></a><a class="code" href="classturn_1_1StunAttrPadding.html">00526</a> <span class="keyword">class </span><a class="code" href="classturn_1_1StunAttrPadding.html">StunAttrPadding</a> : <span class="keyword">public</span> <a class="code" href="classturn_1_1StunAttr.html">StunAttr</a> {
<a name="l00527"></a>00527 <span class="keyword">public</span>:
<a name="l00528"></a><a class="code" href="classturn_1_1StunAttrPadding.html#af8a89c14bbe3b4a6a314ff6d1d0cef56">00528</a>         <a class="code" href="classturn_1_1StunAttrPadding.html#af8a89c14bbe3b4a6a314ff6d1d0cef56">StunAttrPadding</a>() : _p(0) {
<a name="l00529"></a>00529                 <a class="code" href="classturn_1_1StunAttr.html#a3b4c326f288d2a0b1b7288db573eef92">setType</a>(STUN_ATTRIBUTE_PADDING);
<a name="l00530"></a>00530         }
<a name="l00531"></a><a class="code" href="classturn_1_1StunAttrPadding.html#a2ac4db8eaed31fcfaafbb5fa9a410e1d">00531</a>         <a class="code" href="classturn_1_1StunAttrPadding.html#af8a89c14bbe3b4a6a314ff6d1d0cef56">StunAttrPadding</a>(<span class="keyword">const</span> <a class="code" href="classturn_1_1StunAttrIterator.html">StunAttrIterator</a> &amp;iter)
<a name="l00532"></a>00532                 <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>, <a class="code" href="classturn_1_1EndOfStunMsgException.html">EndOfStunMsgException</a>) :
<a name="l00533"></a>00533                 <a class="code" href="classturn_1_1StunAttr.html#aa31465ae7cf4f3664f8e30bc6f7bfb72">StunAttr</a>(iter) {
<a name="l00534"></a>00534 
<a name="l00535"></a>00535                 <span class="keywordflow">if</span>(iter.eof())
<a name="l00536"></a>00536                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1EndOfStunMsgException.html">EndOfStunMsgException</a>();
<a name="l00537"></a>00537 
<a name="l00538"></a>00538                 <span class="keywordtype">int</span> p = <a class="code" href="ns__turn__msg_8h.html#a228b194bc2694f0f1acccf053008e39e">stun_attr_get_padding_len_str</a>(<a class="code" href="classturn_1_1StunAttr.html#a2d7219513d0a946907b0a2402132ddff">getSar</a>(iter));
<a name="l00539"></a>00539                 <span class="keywordflow">if</span>(p&lt;0) {
<a name="l00540"></a>00540                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>();
<a name="l00541"></a>00541                 }
<a name="l00542"></a>00542                 _p = (u16bits)p;
<a name="l00543"></a>00543         }
<a name="l00544"></a><a class="code" href="classturn_1_1StunAttrPadding.html#ae5fe1572dfc8840aef6afef974c92ae1">00544</a>         <span class="keyword">virtual</span> <a class="code" href="classturn_1_1StunAttrPadding.html#ae5fe1572dfc8840aef6afef974c92ae1">~StunAttrPadding</a>() {}
<a name="l00545"></a><a class="code" href="classturn_1_1StunAttrPadding.html#afe31d8b7b5a8778248a704c760ba5da0">00545</a>         u16bits <a class="code" href="classturn_1_1StunAttrPadding.html#afe31d8b7b5a8778248a704c760ba5da0">getPadding</a>()<span class="keyword"> const </span>{
<a name="l00546"></a>00546                 <span class="keywordflow">return</span> _p;
<a name="l00547"></a>00547         }
<a name="l00551"></a><a class="code" href="classturn_1_1StunAttrPadding.html#aa245080b6663b4460e40450b9907d7fd">00551</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunAttrPadding.html#aa245080b6663b4460e40450b9907d7fd">setPadding</a>(u16bits p) {
<a name="l00552"></a>00552                 _p = p;
<a name="l00553"></a>00553         }
<a name="l00554"></a>00554 <span class="keyword">protected</span>:
<a name="l00555"></a><a class="code" href="classturn_1_1StunAttrPadding.html#a071922e9e06c84f9a21592c201cee1c9">00555</a>         <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classturn_1_1StunAttrPadding.html#a071922e9e06c84f9a21592c201cee1c9">addToBuffer</a>(u08bits *buffer, <span class="keywordtype">size_t</span> &amp;sz) <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>, <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) {
<a name="l00556"></a>00556                 <span class="keywordflow">return</span> <a class="code" href="ns__turn__msg_8h.html#a29126998d9a118d604a12524e292bfec">stun_attr_add_padding_str</a>(buffer, &amp;sz, _p);
<a name="l00557"></a>00557         }
<a name="l00558"></a>00558 <span class="keyword">private</span>:
<a name="l00559"></a>00559         u16bits _p;
<a name="l00560"></a>00560 };
<a name="l00561"></a>00561 
<a name="l00565"></a><a class="code" href="classturn_1_1StunMsg.html">00565</a> <span class="keyword">class </span><a class="code" href="classturn_1_1StunMsg.html">StunMsg</a> {
<a name="l00566"></a>00566 <span class="keyword">public</span>:
<a name="l00570"></a><a class="code" href="classturn_1_1StunMsg.html#a96595cee419124a84d6bfa73407da683">00570</a>         <a class="code" href="classturn_1_1StunMsg.html#a96595cee419124a84d6bfa73407da683">StunMsg</a>() {
<a name="l00571"></a>00571                 <a class="code" href="classturn_1_1StunMsg.html#aa66cd88412cd71f7edaf5189eba2ab44">_allocated_sz</a> = 0xFFFF;
<a name="l00572"></a>00572                 <a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a> = (u08bits*)turn_malloc(<a class="code" href="classturn_1_1StunMsg.html#aa66cd88412cd71f7edaf5189eba2ab44">_allocated_sz</a>);
<a name="l00573"></a>00573                 <a class="code" href="classturn_1_1StunMsg.html#a52a1a6acd969948c4c589b0023091cbb">_deallocate</a> = <span class="keyword">true</span>;
<a name="l00574"></a>00574                 <a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a> = 0;
<a name="l00575"></a>00575                 <a class="code" href="classturn_1_1StunMsg.html#ac00be2fea5b4ab929ea6078871ec33d8">_constructed</a> = 0;
<a name="l00576"></a>00576         }
<a name="l00577"></a>00577 
<a name="l00582"></a><a class="code" href="classturn_1_1StunMsg.html#adb103ee966a4fbe46ae6496afcd20b2b">00582</a>         <a class="code" href="classturn_1_1StunMsg.html#a96595cee419124a84d6bfa73407da683">StunMsg</a>(u08bits *buffer, <span class="keywordtype">size_t</span> total_sz, <span class="keywordtype">size_t</span> sz, <span class="keywordtype">bool</span> constructed) :
<a name="l00583"></a>00583                 <a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>(buffer), <a class="code" href="classturn_1_1StunMsg.html#a52a1a6acd969948c4c589b0023091cbb">_deallocate</a>(false), <a class="code" href="classturn_1_1StunMsg.html#aa66cd88412cd71f7edaf5189eba2ab44">_allocated_sz</a>(total_sz),
<a name="l00584"></a>00584                 <a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>(sz), <a class="code" href="classturn_1_1StunMsg.html#ac00be2fea5b4ab929ea6078871ec33d8">_constructed</a>(constructed) {}
<a name="l00585"></a>00585 
<a name="l00589"></a><a class="code" href="classturn_1_1StunMsg.html#adb46577dfeff028f10e40b699b3c6b3f">00589</a>         <span class="keyword">virtual</span> <a class="code" href="classturn_1_1StunMsg.html#adb46577dfeff028f10e40b699b3c6b3f">~StunMsg</a>() {
<a name="l00590"></a>00590                 <span class="keywordflow">if</span>(<a class="code" href="classturn_1_1StunMsg.html#a52a1a6acd969948c4c589b0023091cbb">_deallocate</a> &amp;&amp; <a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>) {
<a name="l00591"></a>00591                         turn_free(<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>, <a class="code" href="classturn_1_1StunMsg.html#aa66cd88412cd71f7edaf5189eba2ab44">_allocated_sz</a>);
<a name="l00592"></a>00592                 }
<a name="l00593"></a>00593         }
<a name="l00594"></a>00594 
<a name="l00598"></a><a class="code" href="classturn_1_1StunMsg.html#abb2d8ac6f2849f158d58a6405c275f54">00598</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunMsg.html#abb2d8ac6f2849f158d58a6405c275f54">construct</a>() {
<a name="l00599"></a>00599                 <a class="code" href="classturn_1_1StunMsg.html#a15530c575e485a35f4d87ba7e117d195">constructBuffer</a>();
<a name="l00600"></a>00600         }
<a name="l00601"></a>00601 
<a name="l00605"></a><a class="code" href="classturn_1_1StunMsg.html#aec1db3118494fb6edc6dc1de9fa06b09">00605</a>         <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunMsg.html#aec1db3118494fb6edc6dc1de9fa06b09">isValid</a>() {
<a name="l00606"></a>00606                 <span class="keywordflow">return</span> <a class="code" href="classturn_1_1StunMsg.html#a9c6452d0d71052a0bda4ded876cc43ea">check</a>();
<a name="l00607"></a>00607         }
<a name="l00608"></a>00608 
<a name="l00612"></a><a class="code" href="classturn_1_1StunMsg.html#ad38c6413489bc2da2e97b661969a5df4">00612</a>         u08bits *<a class="code" href="classturn_1_1StunMsg.html#ad38c6413489bc2da2e97b661969a5df4">getRawBuffer</a>() {
<a name="l00613"></a>00613                 <span class="keywordflow">return</span> <a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>;
<a name="l00614"></a>00614         }
<a name="l00615"></a>00615 
<a name="l00619"></a><a class="code" href="classturn_1_1StunMsg.html#a0729732bfa90be8239a4c662cf24f0af">00619</a>         <span class="keywordtype">size_t</span> <a class="code" href="classturn_1_1StunMsg.html#a0729732bfa90be8239a4c662cf24f0af">getSize</a>()<span class="keyword"> const </span>{
<a name="l00620"></a>00620                 <span class="keywordflow">return</span> <a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>;
<a name="l00621"></a>00621         }
<a name="l00622"></a>00622 
<a name="l00626"></a><a class="code" href="classturn_1_1StunMsg.html#a9daf40e77846a41fe503387285d73a01">00626</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunMsg.html#a9daf40e77846a41fe503387285d73a01">setSize</a>(<span class="keywordtype">size_t</span> sz) <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) {
<a name="l00627"></a>00627                 <span class="keywordflow">if</span>(sz&gt;<a class="code" href="classturn_1_1StunMsg.html#aa66cd88412cd71f7edaf5189eba2ab44">_allocated_sz</a>)
<a name="l00628"></a>00628                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>();
<a name="l00629"></a>00629                 <a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a> = sz;
<a name="l00630"></a>00630         }
<a name="l00631"></a>00631 
<a name="l00635"></a><a class="code" href="classturn_1_1StunMsg.html#ac862fc959f44ef8287e6374e55580a0d">00635</a>         <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunMsg.html#ac862fc959f44ef8287e6374e55580a0d">isCommand</a>(u08bits *buffer, <span class="keywordtype">size_t</span> sz) {
<a name="l00636"></a>00636                 <span class="keywordflow">return</span> <a class="code" href="ns__turn__msg_8h.html#a0ec34e642f8cbf785ecef76f7fb0d87b">stun_is_command_message_str</a>(buffer, sz);
<a name="l00637"></a>00637         }
<a name="l00638"></a>00638 
<a name="l00642"></a><a class="code" href="classturn_1_1StunMsg.html#ac4eb10588a98f213876635943bdb358c">00642</a>         <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunMsg.html#ac4eb10588a98f213876635943bdb358c">isCommand</a>()<span class="keyword"> const </span>{
<a name="l00643"></a>00643                 <span class="keywordflow">return</span> <a class="code" href="ns__turn__msg_8h.html#a0ec34e642f8cbf785ecef76f7fb0d87b">stun_is_command_message_str</a>(<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>, <a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>);
<a name="l00644"></a>00644         }
<a name="l00645"></a>00645 
<a name="l00646"></a><a class="code" href="classturn_1_1StunMsg.html#a4cf1d3727ffd8e2c09e834f30c91db30">00646</a>         <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunMsg.html#a4cf1d3727ffd8e2c09e834f30c91db30">isIndication</a>(u08bits *buffer, <span class="keywordtype">size_t</span> sz) {
<a name="l00647"></a>00647                 <span class="keywordflow">return</span> <a class="code" href="ns__turn__msg_8h.html#a5eea6f087499dad7e35c950b30b0f5cf">stun_is_indication_str</a>(buffer, sz);
<a name="l00648"></a>00648         }
<a name="l00649"></a>00649 
<a name="l00650"></a><a class="code" href="classturn_1_1StunMsg.html#a9d9c109a0dcb34c63282c2990b4e3616">00650</a>         <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunMsg.html#a9d9c109a0dcb34c63282c2990b4e3616">isRequest</a>(u08bits *buffer, <span class="keywordtype">size_t</span> sz) {
<a name="l00651"></a>00651                 <span class="keywordflow">return</span> <a class="code" href="ns__turn__msg_8h.html#a056f82760a5c80f0bc497872d534045b">stun_is_request_str</a>(buffer, sz);
<a name="l00652"></a>00652         }
<a name="l00653"></a>00653 
<a name="l00654"></a><a class="code" href="classturn_1_1StunMsg.html#aa4c2c43d46e7fa788a0fa40e1ad38aa4">00654</a>         <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunMsg.html#aa4c2c43d46e7fa788a0fa40e1ad38aa4">isSuccessResponse</a>(u08bits *buffer, <span class="keywordtype">size_t</span> sz) {
<a name="l00655"></a>00655                 <span class="keywordflow">return</span> <a class="code" href="ns__turn__msg_8h.html#a94312a39c2c9f79b8f89bc3b70105186">stun_is_success_response_str</a>(buffer, sz);
<a name="l00656"></a>00656         }
<a name="l00657"></a>00657 
<a name="l00658"></a><a class="code" href="classturn_1_1StunMsg.html#a208cd843b0457ca8b7282d64fde0b0d1">00658</a>         <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunMsg.html#a208cd843b0457ca8b7282d64fde0b0d1">isErrorResponse</a>(u08bits *buffer, <span class="keywordtype">size_t</span> sz,
<a name="l00659"></a>00659                                         <span class="keywordtype">int</span> &amp;err_code, u08bits *err_msg, <span class="keywordtype">size_t</span> err_msg_size) {
<a name="l00660"></a>00660                 <span class="keywordflow">return</span> <a class="code" href="ns__turn__msg_8h.html#ac73cfbf0bdd56b17d57927aefa7673d8">stun_is_error_response_str</a>(buffer, sz, &amp;err_code, err_msg, err_msg_size);
<a name="l00661"></a>00661         }
<a name="l00662"></a>00662 
<a name="l00666"></a><a class="code" href="classturn_1_1StunMsg.html#a652f008b8556b550184be4c1f7126129">00666</a>         <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunMsg.html#a652f008b8556b550184be4c1f7126129">isChallengeResponse</a>(<span class="keyword">const</span> u08bits* buf, <span class="keywordtype">size_t</span> sz,
<a name="l00667"></a>00667                                         <span class="keywordtype">int</span> &amp;err_code, u08bits *err_msg, <span class="keywordtype">size_t</span> err_msg_size,
<a name="l00668"></a>00668                                         u08bits *realm, u08bits *nonce) {
<a name="l00669"></a>00669                 <span class="keywordflow">return</span> <a class="code" href="ns__turn__msg_8h.html#a0fd8b30d2c2684c12355a1f416d0be71">stun_is_challenge_response_str</a>(buf, sz, &amp;err_code, err_msg, err_msg_size, realm, nonce);
<a name="l00670"></a>00670         }
<a name="l00671"></a>00671 
<a name="l00675"></a><a class="code" href="classturn_1_1StunMsg.html#ad3afc9794256ca780b3b2446b668af78">00675</a>         <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunMsg.html#ad3afc9794256ca780b3b2446b668af78">isChannel</a>(u08bits *buffer, <span class="keywordtype">size_t</span> sz) {
<a name="l00676"></a>00676                 <span class="keywordflow">return</span> <a class="code" href="ns__turn__msg_8h.html#a1751b7757b11749c6a75a13e4f444e49">is_channel_msg_str</a>(buffer, sz);
<a name="l00677"></a>00677         }
<a name="l00678"></a>00678 
<a name="l00682"></a><a class="code" href="classturn_1_1StunMsg.html#a86040d4a52cc5748adaef171dc130f43">00682</a>         <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunMsg.html#a86040d4a52cc5748adaef171dc130f43">isFingerprintPresent</a>(u08bits *buffer, <span class="keywordtype">size_t</span> sz) {
<a name="l00683"></a>00683                 <span class="keywordflow">if</span>(!<a class="code" href="ns__turn__msg_8h.html#a0ec34e642f8cbf785ecef76f7fb0d87b">stun_is_command_message_str</a>(buffer,sz))
<a name="l00684"></a>00684                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00685"></a>00685                 <a class="code" href="ns__turn__msg_8h.html#ad78e84b431d789f6799b3dabf786e032">stun_attr_ref</a> sar = <a class="code" href="ns__turn__msg_8h.html#a05ac5979839241de8b46e4ebdc145722">stun_attr_get_first_by_type_str</a>(buffer, sz, STUN_ATTRIBUTE_FINGERPRINT);
<a name="l00686"></a>00686                 <span class="keywordflow">if</span>(!sar)
<a name="l00687"></a>00687                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00688"></a>00688 
<a name="l00689"></a>00689                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00690"></a>00690         }
<a name="l00691"></a>00691 
<a name="l00695"></a><a class="code" href="classturn_1_1StunMsg.html#a82e38b948a20bbd09d59fa74463edb3a">00695</a>         <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunMsg.html#a82e38b948a20bbd09d59fa74463edb3a">checkFingerprint</a>(u08bits *buffer, <span class="keywordtype">size_t</span> sz) {
<a name="l00696"></a>00696                 <span class="keywordflow">return</span> <a class="code" href="ns__turn__msg_8h.html#a8bd3ed5e7a38ef21a43b12b66f9d8e4c">stun_is_command_message_full_check_str</a>(buffer, sz, 1);
<a name="l00697"></a>00697         }
<a name="l00698"></a>00698 
<a name="l00702"></a><a class="code" href="classturn_1_1StunMsg.html#ad187176401ef8f1a7a09caef24aeb510">00702</a>         <span class="keywordtype">int</span> <a class="code" href="classturn_1_1StunMsg.html#ad187176401ef8f1a7a09caef24aeb510">addAttr</a>(<a class="code" href="classturn_1_1StunAttr.html">StunAttr</a> &amp;attr) <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunAttrFormatException.html">WrongStunAttrFormatException</a>, <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) {
<a name="l00703"></a>00703                 <span class="keywordflow">return</span> attr.addToMsg(*<span class="keyword">this</span>);
<a name="l00704"></a>00704         }
<a name="l00705"></a>00705 
<a name="l00709"></a><a class="code" href="classturn_1_1StunMsg.html#aaf2fca4a2160e482b64c6cc076084124">00709</a>         <span class="keyword">virtual</span> <a class="code" href="structstun__tid.html">stun_tid</a> <a class="code" href="classturn_1_1StunMsg.html#aaf2fca4a2160e482b64c6cc076084124">getTid</a>() <span class="keyword">const</span> throw(<a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) {
<a name="l00710"></a>00710                 <span class="keywordflow">if</span>(!<a class="code" href="classturn_1_1StunMsg.html#ac00be2fea5b4ab929ea6078871ec33d8">_constructed</a> || !<a class="code" href="classturn_1_1StunMsg.html#ac4eb10588a98f213876635943bdb358c">isCommand</a>())
<a name="l00711"></a>00711                         <span class="keywordflow">throw</span> WrongStunBufferFormatException();
<a name="l00712"></a>00712                 <a class="code" href="structstun__tid.html">stun_tid</a> tid;
<a name="l00713"></a>00713                 <a class="code" href="ns__turn__msg_8h.html#a49eaa17067381e5a8bb87032689c9215">stun_tid_from_message_str</a>(<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>,<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>,&amp;tid);
<a name="l00714"></a>00714                 <span class="keywordflow">return</span> tid;
<a name="l00715"></a>00715         }
<a name="l00716"></a>00716 
<a name="l00720"></a><a class="code" href="classturn_1_1StunMsg.html#afd4f7f0ed495aa38cb005742cbac1991">00720</a>         <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunMsg.html#afd4f7f0ed495aa38cb005742cbac1991">setTid</a>(<a class="code" href="structstun__tid.html">stun_tid</a> &amp;tid) <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) {
<a name="l00721"></a>00721                 <span class="keywordflow">if</span>(!<a class="code" href="classturn_1_1StunMsg.html#ac00be2fea5b4ab929ea6078871ec33d8">_constructed</a> || !<a class="code" href="classturn_1_1StunMsg.html#ac4eb10588a98f213876635943bdb358c">isCommand</a>())
<a name="l00722"></a>00722                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>();
<a name="l00723"></a>00723                 <a class="code" href="ns__turn__msg_8h.html#acf7c497e533584cc5c150839393851bb">stun_tid_message_cpy</a>(<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>, &amp;tid);
<a name="l00724"></a>00724         }
<a name="l00725"></a>00725 
<a name="l00729"></a><a class="code" href="classturn_1_1StunMsg.html#a3c4002d2c562f1137324c9d302e8e8e2">00729</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunMsg.html#a3c4002d2c562f1137324c9d302e8e8e2">addFingerprint</a>() throw(<a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) {
<a name="l00730"></a>00730                 <span class="keywordflow">if</span>(!<a class="code" href="classturn_1_1StunMsg.html#ac00be2fea5b4ab929ea6078871ec33d8">_constructed</a> || !<a class="code" href="classturn_1_1StunMsg.html#ac4eb10588a98f213876635943bdb358c">isCommand</a>())
<a name="l00731"></a>00731                         <span class="keywordflow">throw</span> WrongStunBufferFormatException();
<a name="l00732"></a>00732                 <a class="code" href="ns__turn__msg_8h.html#aa55f64405c3498fc12b22bb7da4393d7">stun_attr_add_fingerprint_str</a>(<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>,&amp;<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>);
<a name="l00733"></a>00733         }
<a name="l00734"></a>00734 
<a name="l00738"></a><a class="code" href="classturn_1_1StunMsg.html#af76ec74762ba24d09beef357fee27369">00738</a>         <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunMsg.html#af76ec74762ba24d09beef357fee27369">checkMessageIntegrity</a>(std::string &amp;uname, std::string &amp;realm, std::string &amp;upwd) <span class="keyword">const</span>
<a name="l00739"></a>00739                 <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) {
<a name="l00740"></a>00740                 <span class="keywordflow">if</span>(!<a class="code" href="classturn_1_1StunMsg.html#ac00be2fea5b4ab929ea6078871ec33d8">_constructed</a> || !<a class="code" href="classturn_1_1StunMsg.html#ac4eb10588a98f213876635943bdb358c">isCommand</a>())
<a name="l00741"></a>00741                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>();
<a name="l00742"></a>00742                 <span class="keywordflow">return</span> (0 == <a class="code" href="ns__turn__msg_8h.html#ac915712e78913a408369413315127a5f">stun_check_message_integrity_str</a>(<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>, <a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>,
<a name="l00743"></a>00743                                 (u08bits *)uname.c_str(), (u08bits *)realm.c_str(), (u08bits *)upwd.c_str()));
<a name="l00744"></a>00744         }
<a name="l00745"></a>00745 
<a name="l00749"></a><a class="code" href="classturn_1_1StunMsg.html#ae3344d108a2e688e2633b40d835ba9ec">00749</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunMsg.html#ae3344d108a2e688e2633b40d835ba9ec">addMessageIntegrity</a>(std::string &amp;uname, std::string &amp;realm, std::string &amp;upwd, std::string &amp;nonce)
<a name="l00750"></a>00750                 <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) {
<a name="l00751"></a>00751 
<a name="l00752"></a>00752                 <span class="keywordflow">if</span>(!<a class="code" href="classturn_1_1StunMsg.html#ac00be2fea5b4ab929ea6078871ec33d8">_constructed</a> || !<a class="code" href="classturn_1_1StunMsg.html#ac4eb10588a98f213876635943bdb358c">isCommand</a>())
<a name="l00753"></a>00753                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>();
<a name="l00754"></a>00754 
<a name="l00755"></a>00755                 <a class="code" href="ns__turn__msg_8h.html#a6f10d977a056cc8f58b7642ed1255cb6">stun_attr_add_integrity_by_user_str</a>(<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>, &amp;<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>,
<a name="l00756"></a>00756                         (u08bits *)uname.c_str(), (u08bits *)realm.c_str(), (u08bits *)upwd.c_str(), (u08bits *)nonce.c_str());
<a name="l00757"></a>00757         }
<a name="l00758"></a>00758 
<a name="l00759"></a>00759 <span class="keyword">protected</span>:
<a name="l00760"></a>00760         <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunMsg.html#a15530c575e485a35f4d87ba7e117d195">constructBuffer</a>() = 0;
<a name="l00761"></a>00761         <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunMsg.html#a9c6452d0d71052a0bda4ded876cc43ea">check</a>() = 0;
<a name="l00762"></a>00762 <span class="keyword">protected</span>:
<a name="l00763"></a><a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">00763</a>         u08bits *<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>;
<a name="l00764"></a><a class="code" href="classturn_1_1StunMsg.html#a52a1a6acd969948c4c589b0023091cbb">00764</a>         <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunMsg.html#a52a1a6acd969948c4c589b0023091cbb">_deallocate</a>;
<a name="l00765"></a><a class="code" href="classturn_1_1StunMsg.html#aa66cd88412cd71f7edaf5189eba2ab44">00765</a>         <span class="keywordtype">size_t</span> <a class="code" href="classturn_1_1StunMsg.html#aa66cd88412cd71f7edaf5189eba2ab44">_allocated_sz</a>;
<a name="l00766"></a><a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">00766</a>         <span class="keywordtype">size_t</span> <a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>;
<a name="l00767"></a><a class="code" href="classturn_1_1StunMsg.html#ac00be2fea5b4ab929ea6078871ec33d8">00767</a>         <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunMsg.html#ac00be2fea5b4ab929ea6078871ec33d8">_constructed</a>;
<a name="l00768"></a>00768 };
<a name="l00769"></a>00769 
<a name="l00773"></a><a class="code" href="classturn_1_1StunMsgRequest.html">00773</a> <span class="keyword">class </span><a class="code" href="classturn_1_1StunMsgRequest.html">StunMsgRequest</a> : <span class="keyword">public</span> <a class="code" href="classturn_1_1StunMsg.html">StunMsg</a> {
<a name="l00774"></a>00774 <span class="keyword">public</span>:
<a name="l00775"></a><a class="code" href="classturn_1_1StunMsgRequest.html#a08084dd04744d1c0885bf5fc8789555a">00775</a>         <a class="code" href="classturn_1_1StunMsgRequest.html#a08084dd04744d1c0885bf5fc8789555a">StunMsgRequest</a>(u16bits method) : _method(method) {};
<a name="l00776"></a><a class="code" href="classturn_1_1StunMsgRequest.html#a167b966efc7317d23d8a97e3edf6cf7d">00776</a>         <a class="code" href="classturn_1_1StunMsgRequest.html#a08084dd04744d1c0885bf5fc8789555a">StunMsgRequest</a>(u08bits *buffer, <span class="keywordtype">size_t</span> total_sz, <span class="keywordtype">size_t</span> sz, <span class="keywordtype">bool</span> constructed)
<a name="l00777"></a>00777                 <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) :
<a name="l00778"></a>00778                         <a class="code" href="classturn_1_1StunMsg.html#a96595cee419124a84d6bfa73407da683">StunMsg</a>(buffer,total_sz,sz,constructed),_method(0) {
<a name="l00779"></a>00779 
<a name="l00780"></a>00780                 <span class="keywordflow">if</span>(constructed) {
<a name="l00781"></a>00781                         <span class="keywordflow">if</span>(!<a class="code" href="ns__turn__msg_8h.html#a056f82760a5c80f0bc497872d534045b">stun_is_request_str</a>(buffer,sz)) {
<a name="l00782"></a>00782                                 <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>();
<a name="l00783"></a>00783                         }
<a name="l00784"></a>00784                         _method = <a class="code" href="ns__turn__msg_8h.html#ad36b53fe3bd0eff2cd84ac9e27ba868e">stun_get_method_str</a>(buffer,sz);
<a name="l00785"></a>00785                 }
<a name="l00786"></a>00786         }
<a name="l00787"></a><a class="code" href="classturn_1_1StunMsgRequest.html#a705005f128c40e383b55aa6148606266">00787</a>         <span class="keyword">virtual</span> <a class="code" href="classturn_1_1StunMsgRequest.html#a705005f128c40e383b55aa6148606266">~StunMsgRequest</a>() {}
<a name="l00788"></a>00788 
<a name="l00792"></a><a class="code" href="classturn_1_1StunMsgRequest.html#a53252547fec0e3272134430ad202fdef">00792</a>         u16bits <a class="code" href="classturn_1_1StunMsgRequest.html#a53252547fec0e3272134430ad202fdef">getMethod</a>()<span class="keyword"> const </span>{
<a name="l00793"></a>00793                 <span class="keywordflow">return</span> _method;
<a name="l00794"></a>00794         }
<a name="l00795"></a>00795 
<a name="l00799"></a><a class="code" href="classturn_1_1StunMsgRequest.html#a77b3d4feeedd071686103bb920109638">00799</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunMsgRequest.html#a77b3d4feeedd071686103bb920109638">setMethod</a>(u16bits method) {
<a name="l00800"></a>00800                 _method = method;
<a name="l00801"></a>00801         }
<a name="l00802"></a>00802 
<a name="l00806"></a><a class="code" href="classturn_1_1StunMsgRequest.html#a5a51b0bf762f434351dc39db81d9f0a0">00806</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunMsgRequest.html#a5a51b0bf762f434351dc39db81d9f0a0">constructBindingRequest</a>() {
<a name="l00807"></a>00807                 <a class="code" href="ns__turn__msg_8h.html#a7ebe60f4317b4dc0cc70ac50435620d3">stun_set_binding_request_str</a>(<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>, &amp;<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>);
<a name="l00808"></a>00808         }
<a name="l00809"></a>00809 
<a name="l00810"></a><a class="code" href="classturn_1_1StunMsgRequest.html#a4e26277db9a9d62fa26b57ac1598b832">00810</a>         <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunMsgRequest.html#a4e26277db9a9d62fa26b57ac1598b832">isBindingRequest</a>()<span class="keyword"> const </span>{
<a name="l00811"></a>00811                 <span class="keywordflow">return</span> <a class="code" href="ns__turn__msg_8h.html#a28fc59311318aaa02ae9a92e7e10b697">stun_is_binding_request_str</a>(<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>,<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>,0);
<a name="l00812"></a>00812         }
<a name="l00813"></a>00813 
<a name="l00817"></a><a class="code" href="classturn_1_1StunMsgRequest.html#a510c21edd510961e41660e9d8adcbd21">00817</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunMsgRequest.html#a510c21edd510961e41660e9d8adcbd21">constructAllocateRequest</a>(u32bits lifetime, <span class="keywordtype">int</span> address_family) {
<a name="l00818"></a>00818                 <a class="code" href="ns__turn__msg_8h.html#a97f8d17fdb478f2e7bc61eab956a7545">stun_set_allocate_request_str</a>(<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>, &amp;<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>, lifetime, address_family);
<a name="l00819"></a>00819         }
<a name="l00820"></a>00820 
<a name="l00824"></a><a class="code" href="classturn_1_1StunMsgRequest.html#a1a41fdaadc24770a28f7ed2e02eecd92">00824</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunMsgRequest.html#a1a41fdaadc24770a28f7ed2e02eecd92">constructChannelBindRequest</a>(<span class="keyword">const</span> ioa_addr &amp;peer_addr, u16bits channel_number) {
<a name="l00825"></a>00825                 <a class="code" href="ns__turn__msg_8h.html#a358a289c2efc5c4c138170502bc66e9f">stun_set_channel_bind_request_str</a>(<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>, &amp;<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>,
<a name="l00826"></a>00826                                         &amp;peer_addr, channel_number);
<a name="l00827"></a>00827         }
<a name="l00828"></a>00828 
<a name="l00829"></a>00829 <span class="keyword">protected</span>:
<a name="l00830"></a><a class="code" href="classturn_1_1StunMsgRequest.html#aaa0f5e09aa1ea41c740d7ea90f41f7e7">00830</a>         <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunMsgRequest.html#aaa0f5e09aa1ea41c740d7ea90f41f7e7">constructBuffer</a>() {
<a name="l00831"></a>00831                 <a class="code" href="ns__turn__msg_8h.html#a636c9ed7eed002113d1f36b752f82091">stun_init_request_str</a>(_method,<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>,&amp;<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>);
<a name="l00832"></a>00832                 <a class="code" href="classturn_1_1StunMsg.html#ac00be2fea5b4ab929ea6078871ec33d8">_constructed</a> = <span class="keyword">true</span>;
<a name="l00833"></a>00833         }
<a name="l00834"></a>00834 
<a name="l00835"></a><a class="code" href="classturn_1_1StunMsgRequest.html#a670d1c36082b90e60705436ce0befeff">00835</a>         <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunMsgRequest.html#a670d1c36082b90e60705436ce0befeff">check</a>() {
<a name="l00836"></a>00836                 <span class="keywordflow">if</span>(!<a class="code" href="classturn_1_1StunMsg.html#ac00be2fea5b4ab929ea6078871ec33d8">_constructed</a>)
<a name="l00837"></a>00837                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00838"></a>00838                 <span class="keywordflow">if</span>(!<a class="code" href="ns__turn__msg_8h.html#a056f82760a5c80f0bc497872d534045b">stun_is_request_str</a>(<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>,<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>)) {
<a name="l00839"></a>00839                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00840"></a>00840                 }
<a name="l00841"></a>00841                 <span class="keywordflow">if</span>(_method != <a class="code" href="ns__turn__msg_8h.html#ad36b53fe3bd0eff2cd84ac9e27ba868e">stun_get_method_str</a>(<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>,<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>)) {
<a name="l00842"></a>00842                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00843"></a>00843                 }
<a name="l00844"></a>00844                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00845"></a>00845         }
<a name="l00846"></a>00846 
<a name="l00847"></a>00847 <span class="keyword">private</span>:
<a name="l00848"></a>00848         u16bits _method;
<a name="l00849"></a>00849 };
<a name="l00850"></a>00850 
<a name="l00854"></a><a class="code" href="classturn_1_1StunMsgResponse.html">00854</a> <span class="keyword">class </span><a class="code" href="classturn_1_1StunMsgResponse.html">StunMsgResponse</a> : <span class="keyword">public</span> <a class="code" href="classturn_1_1StunMsg.html">StunMsg</a> {
<a name="l00855"></a>00855 <span class="keyword">public</span>:
<a name="l00856"></a><a class="code" href="classturn_1_1StunMsgResponse.html#a2711bd129549ec120158edb3adc78b6e">00856</a>         <a class="code" href="classturn_1_1StunMsgResponse.html#a2711bd129549ec120158edb3adc78b6e">StunMsgResponse</a>(u16bits method, <a class="code" href="structstun__tid.html">stun_tid</a> &amp;tid) : _method(method), _err(0), _reason(<span class="stringliteral">&quot;&quot;</span>), _tid(tid) {};
<a name="l00857"></a><a class="code" href="classturn_1_1StunMsgResponse.html#a27286d74060e1d798dc443830198ecc7">00857</a>         <a class="code" href="classturn_1_1StunMsgResponse.html#a2711bd129549ec120158edb3adc78b6e">StunMsgResponse</a>(u16bits method, <span class="keywordtype">int</span> error_code, std::string reason, <a class="code" href="structstun__tid.html">stun_tid</a> &amp;tid) :
<a name="l00858"></a>00858                 _method(method), _err(error_code), _reason(reason), _tid(tid) {
<a name="l00859"></a>00859 
<a name="l00860"></a>00860         };
<a name="l00861"></a><a class="code" href="classturn_1_1StunMsgResponse.html#a08d38d9a7ea603c98a729ae55b34a1a5">00861</a>         <a class="code" href="classturn_1_1StunMsgResponse.html#a2711bd129549ec120158edb3adc78b6e">StunMsgResponse</a>(u08bits *buffer, <span class="keywordtype">size_t</span> total_sz, <span class="keywordtype">size_t</span> sz, <span class="keywordtype">bool</span> constructed)
<a name="l00862"></a>00862                 <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) :
<a name="l00863"></a>00863                         <a class="code" href="classturn_1_1StunMsg.html#a96595cee419124a84d6bfa73407da683">StunMsg</a>(buffer,total_sz,sz,constructed),_method(0),_err(0),_reason(<span class="stringliteral">&quot;&quot;</span>) {
<a name="l00864"></a>00864 
<a name="l00865"></a>00865                 <span class="keywordflow">if</span>(constructed) {
<a name="l00866"></a>00866                         <span class="keywordflow">if</span>(!<a class="code" href="ns__turn__msg_8h.html#a94312a39c2c9f79b8f89bc3b70105186">stun_is_success_response_str</a>(buffer,sz)) {
<a name="l00867"></a>00867                                 u08bits errtxt[0xFFFF];
<a name="l00868"></a>00868                                 <span class="keywordflow">if</span>(!<a class="code" href="ns__turn__msg_8h.html#ac73cfbf0bdd56b17d57927aefa7673d8">stun_is_error_response_str</a>(buffer,sz,&amp;_err,errtxt,<span class="keyword">sizeof</span>(errtxt))) {
<a name="l00869"></a>00869                                         <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>();
<a name="l00870"></a>00870                                 }
<a name="l00871"></a>00871                                 _reason = (<span class="keywordtype">char</span>*)errtxt;
<a name="l00872"></a>00872                         }
<a name="l00873"></a>00873                         _method = <a class="code" href="ns__turn__msg_8h.html#ad36b53fe3bd0eff2cd84ac9e27ba868e">stun_get_method_str</a>(buffer,sz);
<a name="l00874"></a>00874                         <a class="code" href="ns__turn__msg_8h.html#a49eaa17067381e5a8bb87032689c9215">stun_tid_from_message_str</a>(<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>,<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>,&amp;_tid);
<a name="l00875"></a>00875                 }
<a name="l00876"></a>00876         }
<a name="l00877"></a>00877 
<a name="l00878"></a><a class="code" href="classturn_1_1StunMsgResponse.html#ace411fb3e6be8571289b7bfa65289469">00878</a>         u16bits <a class="code" href="classturn_1_1StunMsgResponse.html#ace411fb3e6be8571289b7bfa65289469">getMethod</a>()<span class="keyword"> const </span>{
<a name="l00879"></a>00879                 <span class="keywordflow">return</span> _method;
<a name="l00880"></a>00880         }
<a name="l00881"></a>00881 
<a name="l00882"></a><a class="code" href="classturn_1_1StunMsgResponse.html#a3402756dc96c4c762d9ee4a2354d2c37">00882</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunMsgResponse.html#a3402756dc96c4c762d9ee4a2354d2c37">setMethod</a>(u16bits method) {
<a name="l00883"></a>00883                 _method = method;
<a name="l00884"></a>00884         }
<a name="l00885"></a>00885 
<a name="l00889"></a><a class="code" href="classturn_1_1StunMsgResponse.html#a015b48d56d20d26577fcc8327a24b8fb">00889</a>         <span class="keywordtype">int</span> <a class="code" href="classturn_1_1StunMsgResponse.html#a015b48d56d20d26577fcc8327a24b8fb">getError</a>()<span class="keyword"> const </span>{
<a name="l00890"></a>00890                 <span class="keywordflow">return</span> _err;
<a name="l00891"></a>00891         }
<a name="l00892"></a>00892 
<a name="l00896"></a><a class="code" href="classturn_1_1StunMsgResponse.html#a50b8e415e84f0902c853fb3b0e816229">00896</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunMsgResponse.html#a50b8e415e84f0902c853fb3b0e816229">setError</a>(<span class="keywordtype">int</span> err) {
<a name="l00897"></a>00897                 _err = err;
<a name="l00898"></a>00898         }
<a name="l00899"></a>00899 
<a name="l00903"></a><a class="code" href="classturn_1_1StunMsgResponse.html#ad6f25135216cbb232351063a41e0169a">00903</a>         std::string <a class="code" href="classturn_1_1StunMsgResponse.html#ad6f25135216cbb232351063a41e0169a">getReason</a>()<span class="keyword"> const </span>{
<a name="l00904"></a>00904                 <span class="keywordflow">return</span> _reason;
<a name="l00905"></a>00905         }
<a name="l00906"></a>00906 
<a name="l00910"></a><a class="code" href="classturn_1_1StunMsgResponse.html#a1df5a68abae6cd68c05e1b71d47f7e39">00910</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunMsgResponse.html#a1df5a68abae6cd68c05e1b71d47f7e39">setReason</a>(std::string reason) {
<a name="l00911"></a>00911                 _reason = reason;
<a name="l00912"></a>00912         }
<a name="l00913"></a>00913 
<a name="l00917"></a><a class="code" href="classturn_1_1StunMsgResponse.html#abe1a0fb7b3753d0ced2a47f5052969c6">00917</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunMsgResponse.html#abe1a0fb7b3753d0ced2a47f5052969c6">setTid</a>(<a class="code" href="structstun__tid.html">stun_tid</a> &amp;tid) <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) {
<a name="l00918"></a>00918                 _tid = tid;
<a name="l00919"></a>00919         }
<a name="l00920"></a>00920 
<a name="l00924"></a><a class="code" href="classturn_1_1StunMsgResponse.html#aa7510a0d7f94b89d479fa128bf5bb66a">00924</a>         <a class="code" href="structstun__tid.html">stun_tid</a> <a class="code" href="classturn_1_1StunMsgResponse.html#aa7510a0d7f94b89d479fa128bf5bb66a">getTid</a>() throw(<a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) {
<a name="l00925"></a>00925                 <span class="keywordflow">return</span> _tid;
<a name="l00926"></a>00926         }
<a name="l00927"></a>00927 
<a name="l00931"></a><a class="code" href="classturn_1_1StunMsgResponse.html#aa13107eff5faec24cb4415f83c4183d9">00931</a>         <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunMsgResponse.html#aa13107eff5faec24cb4415f83c4183d9">isChallenge</a>(std::string &amp;realm, std::string &amp;nonce)<span class="keyword"> const </span>{
<a name="l00932"></a>00932                 <span class="keywordtype">bool</span> ret = <span class="keyword">false</span>;
<a name="l00933"></a>00933                 <span class="keywordflow">if</span>(<a class="code" href="classturn_1_1StunMsg.html#ac00be2fea5b4ab929ea6078871ec33d8">_constructed</a>) {
<a name="l00934"></a>00934                         <span class="keywordtype">int</span> err_code;
<a name="l00935"></a>00935                         u08bits err_msg[1025];
<a name="l00936"></a>00936                         <span class="keywordtype">size_t</span> err_msg_size=<span class="keyword">sizeof</span>(err_msg);
<a name="l00937"></a>00937                         u08bits srealm[0xFFFF];
<a name="l00938"></a>00938                         u08bits snonce[0xFFFF];
<a name="l00939"></a>00939                         ret = <a class="code" href="ns__turn__msg_8h.html#a0fd8b30d2c2684c12355a1f416d0be71">stun_is_challenge_response_str</a>(<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>, <a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>, &amp;err_code, err_msg, err_msg_size, srealm, snonce);
<a name="l00940"></a>00940                         <span class="keywordflow">if</span>(ret) {
<a name="l00941"></a>00941                                 realm = (<span class="keywordtype">char</span>*)srealm;
<a name="l00942"></a>00942                                 nonce = (<span class="keywordtype">char</span>*)snonce;
<a name="l00943"></a>00943                         }
<a name="l00944"></a>00944                 }
<a name="l00945"></a>00945                 <span class="keywordflow">return</span> ret;
<a name="l00946"></a>00946         }
<a name="l00947"></a>00947 
<a name="l00948"></a><a class="code" href="classturn_1_1StunMsgResponse.html#afb1272d9a7ef47752506fcdd53033843">00948</a>         <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunMsgResponse.html#afb1272d9a7ef47752506fcdd53033843">isChallenge</a>()<span class="keyword"> const </span>{
<a name="l00949"></a>00949                 std::string realm, nonce;
<a name="l00950"></a>00950                 <span class="keywordflow">return</span> <a class="code" href="classturn_1_1StunMsgResponse.html#afb1272d9a7ef47752506fcdd53033843">isChallenge</a>(realm, nonce);
<a name="l00951"></a>00951         }
<a name="l00952"></a>00952 
<a name="l00956"></a><a class="code" href="classturn_1_1StunMsgResponse.html#a08663fcaf87fa75784f1be1f6c15b5f6">00956</a>         <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunMsgResponse.html#a08663fcaf87fa75784f1be1f6c15b5f6">isSuccess</a>()<span class="keyword"> const </span>{
<a name="l00957"></a>00957                 <span class="keywordflow">return</span> (_err == 0);
<a name="l00958"></a>00958         }
<a name="l00959"></a>00959 
<a name="l00963"></a><a class="code" href="classturn_1_1StunMsgResponse.html#a43503b954af564da59f9777c7527bb33">00963</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunMsgResponse.html#a43503b954af564da59f9777c7527bb33">constructBindingResponse</a>(<a class="code" href="structstun__tid.html">stun_tid</a> &amp;tid,
<a name="l00964"></a>00964                                 <span class="keyword">const</span> ioa_addr &amp;reflexive_addr, <span class="keywordtype">int</span> error_code,
<a name="l00965"></a>00965                                 <span class="keyword">const</span> u08bits *reason) {
<a name="l00966"></a>00966 
<a name="l00967"></a>00967                 <a class="code" href="ns__turn__msg_8h.html#a5448e5280f0267a90b1639457f8b4873">stun_set_binding_response_str</a>(<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>, &amp;<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>, &amp;tid,
<a name="l00968"></a>00968                                         &amp;reflexive_addr, error_code,
<a name="l00969"></a>00969                                         reason);
<a name="l00970"></a>00970         }
<a name="l00971"></a>00971 
<a name="l00972"></a><a class="code" href="classturn_1_1StunMsgResponse.html#afce6f0043e1bdfca9ebe1c8b9114486e">00972</a>         <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunMsgResponse.html#afce6f0043e1bdfca9ebe1c8b9114486e">isBindingResponse</a>()<span class="keyword"> const </span>{
<a name="l00973"></a>00973                 <span class="keywordflow">return</span> <a class="code" href="ns__turn__msg_8h.html#a396d7367745ba09aab0b2ae55970f253">stun_is_binding_response_str</a>(<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>,<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>);
<a name="l00974"></a>00974         }
<a name="l00975"></a>00975 
<a name="l00979"></a><a class="code" href="classturn_1_1StunMsgResponse.html#aaf5ffcd9cdff8108c22f920c970cd534">00979</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunMsgResponse.html#aaf5ffcd9cdff8108c22f920c970cd534">constructAllocateResponse</a>(<a class="code" href="structstun__tid.html">stun_tid</a> &amp;tid,
<a name="l00980"></a>00980                                            <span class="keyword">const</span> ioa_addr &amp;relayed_addr,
<a name="l00981"></a>00981                                            <span class="keyword">const</span> ioa_addr &amp;reflexive_addr,
<a name="l00982"></a>00982                                            u32bits lifetime, <span class="keywordtype">int</span> error_code, <span class="keyword">const</span> u08bits *reason,
<a name="l00983"></a>00983                                            u64bits reservation_token) {
<a name="l00984"></a>00984 
<a name="l00985"></a>00985                 <a class="code" href="ns__turn__msg_8h.html#aee82ab41df25d90b52bc4da2ac4520b1">stun_set_allocate_response_str</a>(<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>, &amp;<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>, &amp;tid,
<a name="l00986"></a>00986                                                    &amp;relayed_addr,
<a name="l00987"></a>00987                                                    &amp;reflexive_addr,
<a name="l00988"></a>00988                                                    lifetime, error_code, reason,
<a name="l00989"></a>00989                                                    reservation_token);
<a name="l00990"></a>00990         }
<a name="l00991"></a>00991 
<a name="l00995"></a><a class="code" href="classturn_1_1StunMsgResponse.html#ae64da83f5eec8c6b762710decbf21211">00995</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunMsgResponse.html#ae64da83f5eec8c6b762710decbf21211">constructChannelBindResponse</a>(<a class="code" href="structstun__tid.html">stun_tid</a> &amp;tid, <span class="keywordtype">int</span> error_code, <span class="keyword">const</span> u08bits *reason) {
<a name="l00996"></a>00996                 <a class="code" href="ns__turn__msg_8h.html#a2d504956fe26d4e78e3e834f9d3d6688">stun_set_channel_bind_response_str</a>(<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>, &amp;<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>, &amp;tid, error_code, reason);
<a name="l00997"></a>00997         }
<a name="l00998"></a>00998 
<a name="l00999"></a>00999 <span class="keyword">protected</span>:
<a name="l01000"></a><a class="code" href="classturn_1_1StunMsgResponse.html#ad75a2b4892d6ddae86da0fb4d0aebbba">01000</a>         <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunMsgResponse.html#ad75a2b4892d6ddae86da0fb4d0aebbba">constructBuffer</a>() {
<a name="l01001"></a>01001                 <span class="keywordflow">if</span>(_err) {
<a name="l01002"></a>01002                         <a class="code" href="ns__turn__msg_8h.html#ad8201c3c337098ca6ed1658d1896d59c">stun_init_error_response_str</a>(_method, <a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>, &amp;<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>, _err, (u08bits*)_reason.c_str(), &amp;_tid);
<a name="l01003"></a>01003                 } <span class="keywordflow">else</span> {
<a name="l01004"></a>01004                         <a class="code" href="ns__turn__msg_8h.html#a61639b20b4a36d89230e93d91784dc50">stun_init_success_response_str</a>(_method, <a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>, &amp;<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>, &amp;_tid);
<a name="l01005"></a>01005                 }
<a name="l01006"></a>01006                 <a class="code" href="classturn_1_1StunMsg.html#ac00be2fea5b4ab929ea6078871ec33d8">_constructed</a> = <span class="keyword">true</span>;
<a name="l01007"></a>01007         }
<a name="l01008"></a>01008 
<a name="l01009"></a><a class="code" href="classturn_1_1StunMsgResponse.html#a64b9f523cdd3558837bc15e193ce336a">01009</a>         <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunMsgResponse.html#a64b9f523cdd3558837bc15e193ce336a">check</a>() {
<a name="l01010"></a>01010                 <span class="keywordflow">if</span>(!<a class="code" href="classturn_1_1StunMsg.html#ac00be2fea5b4ab929ea6078871ec33d8">_constructed</a>)
<a name="l01011"></a>01011                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l01012"></a>01012                 <span class="keywordflow">if</span>(!<a class="code" href="ns__turn__msg_8h.html#a94312a39c2c9f79b8f89bc3b70105186">stun_is_success_response_str</a>(<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>,<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>)) {
<a name="l01013"></a>01013                         u08bits errtxt[0xFFFF];
<a name="l01014"></a>01014                         <span class="keywordtype">int</span> cerr=0;
<a name="l01015"></a>01015                         <span class="keywordflow">if</span>(!<a class="code" href="ns__turn__msg_8h.html#ac73cfbf0bdd56b17d57927aefa7673d8">stun_is_error_response_str</a>(<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>,<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>,&amp;cerr,errtxt,<span class="keyword">sizeof</span>(errtxt))) {
<a name="l01016"></a>01016                                 <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>();
<a name="l01017"></a>01017                         }
<a name="l01018"></a>01018                         <span class="keywordflow">if</span>(cerr != _err) {
<a name="l01019"></a>01019                                 <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>();
<a name="l01020"></a>01020                         }
<a name="l01021"></a>01021                 }
<a name="l01022"></a>01022                 <span class="keywordflow">if</span>(_method != <a class="code" href="ns__turn__msg_8h.html#ad36b53fe3bd0eff2cd84ac9e27ba868e">stun_get_method_str</a>(<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>,<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>)) {
<a name="l01023"></a>01023                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l01024"></a>01024                 }
<a name="l01025"></a>01025                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l01026"></a>01026         }
<a name="l01027"></a>01027 
<a name="l01028"></a>01028 <span class="keyword">private</span>:
<a name="l01029"></a>01029         u16bits _method;
<a name="l01030"></a>01030         <span class="keywordtype">int</span> _err;
<a name="l01031"></a>01031         std::string _reason;
<a name="l01032"></a>01032         <a class="code" href="structstun__tid.html">stun_tid</a> _tid;
<a name="l01033"></a>01033 };
<a name="l01034"></a>01034 
<a name="l01038"></a><a class="code" href="classturn_1_1StunMsgIndication.html">01038</a> <span class="keyword">class </span><a class="code" href="classturn_1_1StunMsgIndication.html">StunMsgIndication</a> : <span class="keyword">public</span> <a class="code" href="classturn_1_1StunMsg.html">StunMsg</a> {
<a name="l01039"></a>01039 <span class="keyword">public</span>:
<a name="l01040"></a><a class="code" href="classturn_1_1StunMsgIndication.html#afe53cc07338c34580498fa2a1481b798">01040</a>         <a class="code" href="classturn_1_1StunMsgIndication.html#afe53cc07338c34580498fa2a1481b798">StunMsgIndication</a>(u16bits method) : _method(method) {};
<a name="l01041"></a><a class="code" href="classturn_1_1StunMsgIndication.html#a9880e809ef3d75f8c9fb93c5142461d3">01041</a>         <a class="code" href="classturn_1_1StunMsgIndication.html#afe53cc07338c34580498fa2a1481b798">StunMsgIndication</a>(u08bits *buffer, <span class="keywordtype">size_t</span> total_sz, <span class="keywordtype">size_t</span> sz, <span class="keywordtype">bool</span> constructed)
<a name="l01042"></a>01042                 <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) :
<a name="l01043"></a>01043                         <a class="code" href="classturn_1_1StunMsg.html#a96595cee419124a84d6bfa73407da683">StunMsg</a>(buffer,total_sz,sz,constructed),_method(0) {
<a name="l01044"></a>01044 
<a name="l01045"></a>01045                 <span class="keywordflow">if</span>(constructed) {
<a name="l01046"></a>01046                         <span class="keywordflow">if</span>(!<a class="code" href="ns__turn__msg_8h.html#a5eea6f087499dad7e35c950b30b0f5cf">stun_is_indication_str</a>(buffer,sz)) {
<a name="l01047"></a>01047                                 <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>();
<a name="l01048"></a>01048                         }
<a name="l01049"></a>01049                         _method = <a class="code" href="ns__turn__msg_8h.html#ad36b53fe3bd0eff2cd84ac9e27ba868e">stun_get_method_str</a>(buffer,sz);
<a name="l01050"></a>01050                 }
<a name="l01051"></a>01051         }
<a name="l01052"></a><a class="code" href="classturn_1_1StunMsgIndication.html#a42c4e36f4ad7f0d25432aeec06385d3e">01052</a>         <span class="keyword">virtual</span> <a class="code" href="classturn_1_1StunMsgIndication.html#a42c4e36f4ad7f0d25432aeec06385d3e">~StunMsgIndication</a>() {}
<a name="l01053"></a>01053 
<a name="l01054"></a><a class="code" href="classturn_1_1StunMsgIndication.html#ae164c7d98c0f8a59f1f8eee3d3f12434">01054</a>         u16bits <a class="code" href="classturn_1_1StunMsgIndication.html#ae164c7d98c0f8a59f1f8eee3d3f12434">getMethod</a>()<span class="keyword"> const </span>{
<a name="l01055"></a>01055                 <span class="keywordflow">return</span> _method;
<a name="l01056"></a>01056         }
<a name="l01057"></a>01057 
<a name="l01058"></a><a class="code" href="classturn_1_1StunMsgIndication.html#a3e9a5ca4afc300c6f861637714a5a8aa">01058</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunMsgIndication.html#a3e9a5ca4afc300c6f861637714a5a8aa">setMethod</a>(u16bits method) {
<a name="l01059"></a>01059                 _method = method;
<a name="l01060"></a>01060         }
<a name="l01061"></a>01061 
<a name="l01062"></a>01062 <span class="keyword">protected</span>:
<a name="l01063"></a><a class="code" href="classturn_1_1StunMsgIndication.html#ad096b14fa48e468ba4b1e944eca01c27">01063</a>         <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunMsgIndication.html#ad096b14fa48e468ba4b1e944eca01c27">constructBuffer</a>() {
<a name="l01064"></a>01064                 <a class="code" href="ns__turn__msg_8h.html#a3624bce5a9fffcc1e2738edf575ecc03">stun_init_indication_str</a>(_method,<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>,&amp;<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>);
<a name="l01065"></a>01065                 <a class="code" href="classturn_1_1StunMsg.html#ac00be2fea5b4ab929ea6078871ec33d8">_constructed</a> = <span class="keyword">true</span>;
<a name="l01066"></a>01066         }
<a name="l01067"></a>01067 
<a name="l01068"></a><a class="code" href="classturn_1_1StunMsgIndication.html#ad31f4bc0d4c88b0eb815bb72094d0b2a">01068</a>         <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunMsgIndication.html#ad31f4bc0d4c88b0eb815bb72094d0b2a">check</a>() {
<a name="l01069"></a>01069                 <span class="keywordflow">if</span>(!<a class="code" href="classturn_1_1StunMsg.html#ac00be2fea5b4ab929ea6078871ec33d8">_constructed</a>)
<a name="l01070"></a>01070                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l01071"></a>01071                 <span class="keywordflow">if</span>(!<a class="code" href="ns__turn__msg_8h.html#a5eea6f087499dad7e35c950b30b0f5cf">stun_is_indication_str</a>(<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>,<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>)) {
<a name="l01072"></a>01072                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l01073"></a>01073                 }
<a name="l01074"></a>01074                 <span class="keywordflow">if</span>(_method != <a class="code" href="ns__turn__msg_8h.html#ad36b53fe3bd0eff2cd84ac9e27ba868e">stun_get_method_str</a>(<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>,<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>)) {
<a name="l01075"></a>01075                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l01076"></a>01076                 }
<a name="l01077"></a>01077                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l01078"></a>01078         }
<a name="l01079"></a>01079 
<a name="l01080"></a>01080 <span class="keyword">private</span>:
<a name="l01081"></a>01081         u16bits _method;
<a name="l01082"></a>01082 };
<a name="l01083"></a>01083 
<a name="l01087"></a><a class="code" href="classturn_1_1StunMsgChannel.html">01087</a> <span class="keyword">class </span><a class="code" href="classturn_1_1StunMsgChannel.html">StunMsgChannel</a> : <span class="keyword">public</span> <a class="code" href="classturn_1_1StunMsg.html">StunMsg</a> {
<a name="l01088"></a>01088 <span class="keyword">public</span>:
<a name="l01089"></a><a class="code" href="classturn_1_1StunMsgChannel.html#a9e2a2b62acf5ad60d306507e94ad3084">01089</a>         <a class="code" href="classturn_1_1StunMsgChannel.html#a9e2a2b62acf5ad60d306507e94ad3084">StunMsgChannel</a>(u16bits cn, <span class="keywordtype">int</span> length) : _cn(cn), _len(length) {};
<a name="l01090"></a><a class="code" href="classturn_1_1StunMsgChannel.html#a5165aa2f12c89bbe7a7cefb5ce929aa7">01090</a>         <a class="code" href="classturn_1_1StunMsgChannel.html#a9e2a2b62acf5ad60d306507e94ad3084">StunMsgChannel</a>(u08bits *buffer, <span class="keywordtype">size_t</span> total_sz, <span class="keywordtype">size_t</span> sz, <span class="keywordtype">bool</span> constructed)
<a name="l01091"></a>01091                 <span class="keywordflow">throw</span>(<a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>) :
<a name="l01092"></a>01092                         <a class="code" href="classturn_1_1StunMsg.html#a96595cee419124a84d6bfa73407da683">StunMsg</a>(buffer,total_sz,sz,constructed),_cn(0) {
<a name="l01093"></a>01093 
<a name="l01094"></a>01094                 <span class="keywordflow">if</span>(constructed) {
<a name="l01095"></a>01095                         <span class="keywordflow">if</span>(!<a class="code" href="ns__turn__msg_8h.html#a840a56d7d91d92cc60ce9f5d2f128647">stun_is_channel_message_str</a>(buffer,sz,&amp;_cn)) {
<a name="l01096"></a>01096                                 <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>();
<a name="l01097"></a>01097                         }
<a name="l01098"></a>01098                         <span class="keywordflow">if</span>(<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>&gt;0xFFFF || <a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>&lt;4)
<a name="l01099"></a>01099                                 <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>();
<a name="l01100"></a>01100 
<a name="l01101"></a>01101                         _len = <a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>-4;
<a name="l01102"></a>01102                 } <span class="keywordflow">else</span> {
<a name="l01103"></a>01103                         <span class="keywordflow">if</span>(total_sz&gt;0xFFFF || total_sz&lt;4)
<a name="l01104"></a>01104                                 <span class="keywordflow">throw</span> <a class="code" href="classturn_1_1WrongStunBufferFormatException.html">WrongStunBufferFormatException</a>();
<a name="l01105"></a>01105 
<a name="l01106"></a>01106                         _len = 0;
<a name="l01107"></a>01107                 }
<a name="l01108"></a>01108         }
<a name="l01109"></a><a class="code" href="classturn_1_1StunMsgChannel.html#a1eca150860372a9fa24e783f8f9ecc7a">01109</a>         <span class="keyword">virtual</span> <a class="code" href="classturn_1_1StunMsgChannel.html#a1eca150860372a9fa24e783f8f9ecc7a">~StunMsgChannel</a>() {}
<a name="l01110"></a>01110 
<a name="l01111"></a><a class="code" href="classturn_1_1StunMsgChannel.html#a33f7a5106eaa80d4c7c73bdadcd7cfef">01111</a>         u16bits <a class="code" href="classturn_1_1StunMsgChannel.html#a33f7a5106eaa80d4c7c73bdadcd7cfef">getChannelNumber</a>()<span class="keyword"> const </span>{
<a name="l01112"></a>01112                 <span class="keywordflow">return</span> _cn;
<a name="l01113"></a>01113         }
<a name="l01114"></a>01114 
<a name="l01115"></a><a class="code" href="classturn_1_1StunMsgChannel.html#a7394df1d9dcee49e2a30bdad55a7b8ad">01115</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunMsgChannel.html#a7394df1d9dcee49e2a30bdad55a7b8ad">setChannelNumber</a>(u16bits cn) {
<a name="l01116"></a>01116                 _cn = cn;
<a name="l01117"></a>01117         }
<a name="l01118"></a>01118 
<a name="l01122"></a><a class="code" href="classturn_1_1StunMsgChannel.html#ad55d3c51cd5882adbc17ab700aea49e5">01122</a>         <span class="keywordtype">size_t</span> <a class="code" href="classturn_1_1StunMsgChannel.html#ad55d3c51cd5882adbc17ab700aea49e5">getLength</a>()<span class="keyword"> const </span>{
<a name="l01123"></a>01123                 <span class="keywordflow">return</span> _len;
<a name="l01124"></a>01124         }
<a name="l01125"></a>01125 
<a name="l01129"></a><a class="code" href="classturn_1_1StunMsgChannel.html#a63c0dc4ff671a8b671f8757cf3518953">01129</a>         <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunMsgChannel.html#a63c0dc4ff671a8b671f8757cf3518953">setLength</a>(<span class="keywordtype">size_t</span> len) {
<a name="l01130"></a>01130                 _len = len;
<a name="l01131"></a>01131         }
<a name="l01132"></a>01132 
<a name="l01133"></a>01133 <span class="keyword">protected</span>:
<a name="l01134"></a><a class="code" href="classturn_1_1StunMsgChannel.html#a8ae19badff2d03f509711e0facd4041e">01134</a>         <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classturn_1_1StunMsgChannel.html#a8ae19badff2d03f509711e0facd4041e">constructBuffer</a>() {
<a name="l01135"></a>01135                 <a class="code" href="ns__turn__msg_8h.html#ac18e6049a1a491b4d7352ad62e418f4a">stun_init_channel_message_str</a>(_cn,<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>,&amp;<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>,(<span class="keywordtype">int</span>)_len);
<a name="l01136"></a>01136                 <a class="code" href="classturn_1_1StunMsg.html#ac00be2fea5b4ab929ea6078871ec33d8">_constructed</a> = <span class="keyword">true</span>;
<a name="l01137"></a>01137         }
<a name="l01138"></a>01138 
<a name="l01139"></a><a class="code" href="classturn_1_1StunMsgChannel.html#a66a94265dda2a2db0dc8565359c861b0">01139</a>         <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classturn_1_1StunMsgChannel.html#a66a94265dda2a2db0dc8565359c861b0">check</a>() {
<a name="l01140"></a>01140                 <span class="keywordflow">if</span>(!<a class="code" href="classturn_1_1StunMsg.html#ac00be2fea5b4ab929ea6078871ec33d8">_constructed</a>)
<a name="l01141"></a>01141                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l01142"></a>01142                 u16bits cn = 0;
<a name="l01143"></a>01143                 <span class="keywordflow">if</span>(!<a class="code" href="ns__turn__msg_8h.html#a840a56d7d91d92cc60ce9f5d2f128647">stun_is_channel_message_str</a>(<a class="code" href="classturn_1_1StunMsg.html#a0222f924d9fc1b9b268ba87c459dd7fd">_buffer</a>,<a class="code" href="classturn_1_1StunMsg.html#aa3c270c8abbdd22abe101907248754a9">_sz</a>,&amp;cn)) {
<a name="l01144"></a>01144                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l01145"></a>01145                 }
<a name="l01146"></a>01146                 <span class="keywordflow">if</span>(_cn != cn) {
<a name="l01147"></a>01147                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l01148"></a>01148                 }
<a name="l01149"></a>01149                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l01150"></a>01150         }
<a name="l01151"></a>01151 
<a name="l01152"></a>01152 <span class="keyword">private</span>:
<a name="l01153"></a>01153         u16bits _cn;
<a name="l01154"></a>01154         <span class="keywordtype">size_t</span> _len;
<a name="l01155"></a>01155 };
<a name="l01156"></a>01156 
<a name="l01157"></a>01157 };
<a name="l01158"></a>01158 <span class="comment">/* namespace */</span>
<a name="l01159"></a>01159 
<a name="l01160"></a>01160 <span class="preprocessor">#endif</span>
<a name="l01161"></a>01161 <span class="preprocessor"></span><span class="comment">/* __LIB_TURN_MSG_CPP__ */</span>
</pre></div></div><!-- contents -->


<hr class="footer"/><address class="footer"><small>
Generated on Tue Jan 22 2013 14:23:54 for TURN Server by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.0
</small></address>

</body>
</html>
